From 2335c6164456e33f38b9e20186cc32420f1986ab Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 22 Sep 2018 01:23:45 +0200 Subject: [PATCH] app/controllers/UserController.php: in activateLinkAction() accept account activation also. --- app/controllers/UserController.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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.'); }