diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
index 0fa005e1f..5a7a5e971 100644
--- a/app/Http/Controllers/Auth/RegisterController.php
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -250,15 +250,27 @@ class RegisterController extends Controller
/**
* The callback for social login services.
* @param $socialDriver
+ * @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws SocialSignInException
+ * @throws UserRegistrationException
+ * @throws \BookStack\Exceptions\SocialDriverNotConfigured
+ * @throws ConfirmationEmailException
*/
- public function socialCallback($socialDriver)
+ public function socialCallback($socialDriver, Request $request)
{
if (!session()->has('social-callback')) {
throw new SocialSignInException(trans('errors.social_no_action_defined'), '/login');
}
+ // Check request for error information
+ if ($request->has('error') && $request->has('error_description')) {
+ throw new SocialSignInException(trans('errors.social_login_bad_response', [
+ 'socialAccount' => $socialDriver,
+ 'error' => $request->get('error_description'),
+ ]), '/login');
+ }
+
$action = session()->pull('social-callback');
if ($action == 'login') return $this->socialAuthService->handleLoginCallback($socialDriver);
if ($action == 'register') return $this->socialRegisterCallback($socialDriver);
@@ -279,7 +291,9 @@ class RegisterController extends Controller
* Register a new user after a registration callback.
* @param $socialDriver
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ * @throws ConfirmationEmailException
* @throws UserRegistrationException
+ * @throws \BookStack\Exceptions\SocialDriverNotConfigured
*/
protected function socialRegisterCallback($socialDriver)
{
diff --git a/app/Services/SocialAuthService.php b/app/Services/SocialAuthService.php
index 6286a6014..d52464539 100644
--- a/app/Services/SocialAuthService.php
+++ b/app/Services/SocialAuthService.php
@@ -1,5 +1,7 @@
validateDriver($socialDriver);
-
// Get user details from social driver
$socialUser = $this->socialite->driver($driver)->user();
$socialId = $socialUser->getId();
@@ -135,7 +136,7 @@ class SocialAuthService
$message .= trans('errors.social_account_register_instructions', ['socialAccount' => title_case($socialDriver)]);
}
- throw new SocialSignInException($message . '.', '/login');
+ throw new SocialSignInException($message, '/login');
}
/**
diff --git a/config/services.php b/config/services.php
index 514720d72..ba9be69de 100644
--- a/config/services.php
+++ b/config/services.php
@@ -81,8 +81,8 @@ return [
],
'okta' => [
- 'client_id' => env('OKTA_KEY'),
- 'client_secret' => env('OKTA_SECRET'),
+ 'client_id' => env('OKTA_APP_ID'),
+ 'client_secret' => env('OKTA_APP_SECRET'),
'redirect' => env('APP_URL') . '/login/service/okta/callback',
'base_url' => env('OKTA_BASE_URL'),
'name' => 'Okta',
diff --git a/resources/assets/icons/okta.svg b/resources/assets/icons/okta.svg
index 3ae0d63a3..b5f3b1d3f 100644
--- a/resources/assets/icons/okta.svg
+++ b/resources/assets/icons/okta.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/resources/lang/en/errors.php b/resources/lang/en/errors.php
index 572bec42b..18ed63c60 100644
--- a/resources/lang/en/errors.php
+++ b/resources/lang/en/errors.php
@@ -20,6 +20,7 @@ return [
'ldap_extension_not_installed' => 'LDAP PHP extension not installed',
'ldap_cannot_connect' => 'Cannot connect to ldap server, Initial connection failed',
'social_no_action_defined' => 'No action defined',
+ 'social_login_bad_response' => "Error received during :socialAccount login: \n:error",
'social_account_in_use' => 'This :socialAccount account is already in use, Try logging in via the :socialAccount option.',
'social_account_email_in_use' => 'The email :email is already in use. If you already have an account you can connect your :socialAccount account from your profile settings.',
'social_account_existing' => 'This :socialAccount is already attached to your profile.',