Skip to content

Commit

Permalink
Fixed rbac roles scenario. Rbac attribute is safe only in 'backend' s…
Browse files Browse the repository at this point in the history
…cenario.

Fixed: password will be empty when login form is loading.
  • Loading branch information
maddoger committed Nov 5, 2015
1 parent 44aa517 commit 1d5386b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions backend/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function actionCreate()
'profile' => new UserProfile(),
],
]);
$model->getModel('user')->setScenario('backend');

if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->getModel('user')->id]);
Expand All @@ -151,6 +152,7 @@ public function actionUpdate($id)
'profile' => $user->profile,
],
]);
$model->getModel('user')->setScenario('backend');

if ($model->load(Yii::$app->request->post()) && $model->save()) {
switch (Yii::$app->request->post('redirect')) {
Expand Down
2 changes: 1 addition & 1 deletion backend/views/auth/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
[
'parts' => ['{feedback}' => '<span class="glyphicon glyphicon-lock form-control-feedback"></span>'],
]
)->passwordInput(['placeholder' => $model->getAttributeLabel('password')]); ?>
)->passwordInput(['placeholder' => $model->getAttributeLabel('password'), 'value' => '']); ?>

<div class="row">
<div class="col-xs-8">
Expand Down
3 changes: 2 additions & 1 deletion common/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ public function rules()
//Create
[['username', 'email', 'password_hash'], 'required', 'on' => 'create'],

[['rbacRoles'], 'safe'],
//Only in backend
[['rbacRoles'], 'safe', 'on' => 'backend'],
];
}

Expand Down

0 comments on commit 1d5386b

Please sign in to comment.