Skip to content

Commit

Permalink
Override behaviour of handle_authentication_callback in duplicated ca…
Browse files Browse the repository at this point in the history
…llback

Fix for “You are already logged in.” error message during login
  • Loading branch information
fabian committed Aug 23, 2024
1 parent 329f610 commit 4533843
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Concrete/Authentication/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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'));
Expand Down

0 comments on commit 4533843

Please sign in to comment.