[英]Assigning roles to a user in registration process [yii (users + auth)]
我在Yii中使用用戶+身份驗證模塊。 我已經使用管理在auth中做了3個角色:
auth/role/
另外,在用戶模塊中
user/profileField
我已經創建了一個個人資料字段,該字段將在注冊頁面中確定,您要創建哪個帳戶
[boolean: true="Company" false="Other"]
管理員帳戶只能在模塊中創建
我想在注冊過程中基於此字段分配角色。 我想我應該用這種方法寫這個(?):
/user/controllers/RegistrationController.php:
public function actionRegistration(){...
...
if ($model->save()) {
$profile->user_id=$model->id;
....my role assign here ?...
$profile->save();
...
順便說一句:直接更改/user/controllers/RegistrationController.php是否優雅?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.