Open neomaximus2k opened 5 years ago
I was able to display a view by throwing an Exception inside the login event.
// app/Exceptions/SsoAuthenticationException.php
namespace App\Exceptions;
use Illuminate\Auth\AuthenticationException;
class SsoAuthenticationException extends AuthenticationException
{
}
// app/Exceptions/Handler.php
...
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($exception instanceof SsoAuthenticationException) {
return redirect()->route('sso-error');
}
return parent::unauthenticated($request, $exception);
}
...
Throwing an exception in the event will now redirect to a route named sso-error
.
throw new SsoAuthenticationException('User not found for ID: '.$user->getUserId())
This approach is kind of awkward, but it works.
@imacrayon Thanks. I've seen awkwarder ;).
It would be good to have more information about this in the Readme.
In the documentation you have the following line
//if it does not exist create it and go on or show an error message
I need to "show an error message" in my system as SSO is using ADFS email to then re-match the user, this doesn't work if their username and email don't match and I need to show an error message asking them to contact the IT support team.
I've attempted to return a view (which I know you shouldn't do) in the event along with a few other options but to no avail. How can I achieve this?
` $Auth = $event->getSaml2Auth(); $User = $event->getSaml2User(); $messageId = $Auth->getLastMessageId();
`