diff --git a/src/UserProviderRedirector.php b/src/UserProviderRedirector.php index cbd527b..bbb1669 100644 --- a/src/UserProviderRedirector.php +++ b/src/UserProviderRedirector.php @@ -12,6 +12,26 @@ class UserProviderRedirector implements ProviderRedirector { + /** + * The URL to redirect to when unable to authenticate the user. + */ + public static string $unableToAuthenticateUserUrl = 'login'; + + /** + * The URL to redirect to when the user already exists. + */ + public static string $userAlreadyExistsUrl = 'login'; + + /** + * The URL to redirect to when unable to create the user. + */ + public static string $unableToCreateUserUrl = 'login'; + + /** + * The URL to redirect to when the user has been successfully authenticated. + */ + public static string $userAuthenticatedUrl = 'dashboard'; + /** * Redirect when unable to authenticate the user. */ @@ -21,7 +41,7 @@ public function unableToAuthenticateUser(Exception $e, string $driver): Redirect $message = sprintf('There was a problem creating your %s account. Please try again.', ucfirst($driver)); - return $this->redirector()->to('login')->with('flash', [ + return $this->redirector()->to(static::$unableToAuthenticateUserUrl)->with('flash', [ 'bannerStyle' => 'danger', 'banner' => $message, ]); @@ -34,7 +54,7 @@ public function userAlreadyExists(SocialiteUser $user, string $driver): Redirect { $message = sprintf("An account with the email address '%s' already exists.", $user->email); - return $this->redirector()->to('login')->with('flash', [ + return $this->redirector()->to(static::$userAlreadyExistsUrl)->with('flash', [ 'bannerStyle' => 'danger', 'banner' => $message, ]); @@ -47,7 +67,7 @@ public function unableToCreateUser(Exception $e, SocialiteUser $user, string $dr { report($e); - return $this->redirector()->to('login')->with('flash', [ + return $this->redirector()->to(static::$unableToCreateUserUrl)->with('flash', [ 'bannerStyle' => 'danger', 'banner' => 'There was a problem creating your account. Please try again.', ]); @@ -62,7 +82,7 @@ public function userAuthenticated(Authenticatable $user, SocialiteUser $socialit Session::regenerate(); - return redirect('dashboard'); + return redirect()->intended(static::$userAuthenticatedUrl); } /**