mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Added login redirect system to confirm/mfa
Also continued a bit on the MFA verification system. Moved some MFA routes to public space using updated login service to get the current user that is either logged in or last attempted login (With correct creds).
This commit is contained in:
40
app/Exceptions/StoppedAuthenticationException.php
Normal file
40
app/Exceptions/StoppedAuthenticationException.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace BookStack\Exceptions;
|
||||
|
||||
use BookStack\Auth\Access\LoginService;
|
||||
use BookStack\Auth\User;
|
||||
use Illuminate\Contracts\Support\Responsable;
|
||||
|
||||
class StoppedAuthenticationException extends \Exception implements Responsable
|
||||
{
|
||||
|
||||
protected $user;
|
||||
protected $loginService;
|
||||
|
||||
/**
|
||||
* StoppedAuthenticationException constructor.
|
||||
*/
|
||||
public function __construct(User $user, LoginService $loginService)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->loginService = $loginService;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function toResponse($request)
|
||||
{
|
||||
$redirect = '/login';
|
||||
|
||||
if ($this->loginService->awaitingEmailConfirmation($this->user)) {
|
||||
$redirect = '/register/confirm/awaiting';
|
||||
} else if ($this->loginService->needsMfaVerification($this->user)) {
|
||||
$redirect = '/mfa/verify';
|
||||
}
|
||||
|
||||
return redirect($redirect);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user