From a0408aa38fed0c8334e3fc3b3785ca45b8eecd9a Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Fri, 5 May 2023 19:32:03 +0400 Subject: [PATCH] Fix automatically login user after registration (#6294) * Fix automatically login user after registration * Update RegistrationController.php --------- Co-authored-by: Lucas Bartholemy --- CHANGELOG.md | 1 + .../modules/user/controllers/RegistrationController.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adca9c77cb..28393d9bd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ HumHub Changelog - Enh #6242: Submit button hidden when editing a comment having a long "code" line - Fix #6282: Hard delete content records on integrity check - Fix #6257: Fix error after publishing of a draft content +- Fix #6273: Fix automatically login user after registration - Fix #6292: Messages: Notification Indicator Problem - Fix #6296: Update style variable `background-color-secondary` diff --git a/protected/humhub/modules/user/controllers/RegistrationController.php b/protected/humhub/modules/user/controllers/RegistrationController.php index 771d285c90..3c0de52dec 100644 --- a/protected/humhub/modules/user/controllers/RegistrationController.php +++ b/protected/humhub/modules/user/controllers/RegistrationController.php @@ -89,8 +89,8 @@ class RegistrationController extends Controller // Autologin when user is enabled (no approval required) if ($registration->getUser()->status === User::STATUS_ENABLED) { - Yii::$app->user->switchIdentity($registration->models['User']); - $registration->models['User']->updateAttributes(['last_login' => date('Y-m-d G:i:s')]); + $registration->getUser()->refresh(); // https://github.com/humhub/humhub/issues/6273 + Yii::$app->user->login($registration->getUser()); if (Yii::$app->request->getIsAjax()) { return $this->htmlRedirect(Yii::$app->user->returnUrl); }