1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Updated OIDC error handling for better error reporting

Fixes issue where certain errors would not show to the user
due to extra navigation jumps which lost the error message
in the process.
This simplifies and aligns exceptions with more directly
handled exception usage at the controller level.

Fixes #3264
This commit is contained in:
Dan Brown
2022-02-24 14:16:09 +00:00
parent 63ce3c9add
commit ce566bea2a
8 changed files with 72 additions and 57 deletions

View File

@ -3,12 +3,13 @@
namespace BookStack\Http\Controllers\Auth;
use BookStack\Auth\Access\Oidc\OidcService;
use BookStack\Auth\Access\Oidc\OidcException;
use BookStack\Http\Controllers\Controller;
use Illuminate\Http\Request;
class OidcController extends Controller
{
protected $oidcService;
protected OidcService $oidcService;
/**
* OpenIdController constructor.
@ -24,7 +25,13 @@ class OidcController extends Controller
*/
public function login()
{
$loginDetails = $this->oidcService->login();
try {
$loginDetails = $this->oidcService->login();
} catch (OidcException $exception) {
$this->showErrorNotification($exception->getMessage());
return redirect('/login');
}
session()->flash('oidc_state', $loginDetails['state']);
return redirect($loginDetails['url']);
@ -45,7 +52,12 @@ class OidcController extends Controller
return redirect('/login');
}
$this->oidcService->processAuthorizeResponse($request->query('code'));
try {
$this->oidcService->processAuthorizeResponse($request->query('code'));
} catch (OidcException $oidcException) {
$this->showErrorNotification($oidcException->getMessage());
return redirect('/login');
}
return redirect()->intended();
}