Archived
1
0
Fork 0

app/controllers/UserController.php: in activateLinkAction() accept account activation also.

This commit is contained in:
Henrik Hautakoski 2018-09-22 01:23:45 +02:00
parent 2faf85359a
commit 2335c61644

View file

@ -107,8 +107,9 @@ class UserController extends ControllerBase
}
/**
* Activate a password.
* Account/Password activation.
*
* @Acl(resource="auth")
* @param $id
*/
public function activationLinkAction($id)
@ -118,12 +119,20 @@ class UserController extends ControllerBase
if ($link) {
if ($link->isValid()) {
// Save the password.
$link->getUser()
->setPassword($link->getPassword())
->save();
$user = $link->getUser();
$this->flash->success('Your password has been activated.');
// Save password if any is set.
if (strlen($link->getPassword()) > 0) {
$user->setPassword($link->getPassword());
$this->flash->success('Your password has been activated.');
} else {
$user->setStatus(User::STATUS_ACTIVE);
$this->flash->success('Your account has been activated.');
// Also login the user.
$this->auth->systemLogin($user);
}
$user->save();
} else {
$this->flash->error('This link has expired or has already been used.');
}