From 4533843333e50e8232a97f79072971271b525a81 Mon Sep 17 00:00:00 2001 From: Fabian Vogler Date: Fri, 23 Aug 2024 17:08:32 +0200 Subject: [PATCH] Override behaviour of handle_authentication_callback in duplicated callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix for “You are already logged in.” error message during login --- src/Concrete/Authentication/Controller.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Concrete/Authentication/Controller.php b/src/Concrete/Authentication/Controller.php index 3f70a4e..ef213e8 100644 --- a/src/Concrete/Authentication/Controller.php +++ b/src/Concrete/Authentication/Controller.php @@ -4,6 +4,7 @@ use Concrete\Core\Authentication\Type\OAuth\OAuth2\GenericOauth2TypeController; use Concrete\Core\User\User; +use Concrete\Core\Routing\RedirectResponse; class Controller extends GenericOauth2TypeController { @@ -43,6 +44,24 @@ public function saveAuthenticationType($args) \Config::save('auth.worldskills.registration.group', intval($args['registration_group'], 10)); } + /** + * @override + */ + public function handle_authentication_callback() + { + // parent handle_authentication_callback redirects to an error page if user is already logged in, + // override the behavior and simply let the logged in user continue + $user = $this->app->make(User::class); + if ($user && !$user->isError() && $user->isLoggedIn()) { + return new RedirectResponse( + $this->app->make('url/manager')->resolve(['/login', 'login_complete']) + ); + } + + // still use parent handle_authentication_callback for all other cases + return parent::handle_authentication_callback(); + } + public function edit() { $this->set('form', \Loader::helper('form'));