diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 5d27d89..3ce35fa 100644 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -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.'); }