Password expiration feature #102

It's still missing an enforcement which redirects all actions to profile
update until the password is changed
This commit is contained in:
Lorenzo Milesi
2017-11-26 20:09:09 +01:00
parent b0d1f159aa
commit 3281169b86
7 changed files with 135 additions and 2 deletions

View File

@ -18,6 +18,7 @@ use Da\User\Model\Profile;
use Da\User\Model\User;
use Da\User\Query\UserQuery;
use Da\User\Search\UserSearch;
use Da\User\Service\PasswordExpireService;
use Da\User\Service\PasswordRecoveryService;
use Da\User\Service\SwitchIdentityService;
use Da\User\Service\UserBlockService;
@ -329,4 +330,20 @@ class AdminController extends Controller
return $this->redirect(['index']);
}
/**
* Forces the user to change password at next login
* @param integer $id
*/
public function actionForcePasswordChange($id)
{
/** @var User $user */
$user = $this->userQuery->where(['id' => $id])->one();
if ($this->make(PasswordExpireService::class, [$user])->run()) {
Yii::$app->session->setFlash("success", Yii::t('usuario', 'User will be required to change password at next login'));
} else {
Yii::$app->session->setFlash("danger", Yii::t('usuario', 'There was an error in saving user'));
}
$this->redirect(['index']);
}
}