Commit 156a1444 authored by Nicolas Widart's avatar Nicolas Widart

Catching sentry exceptions

parent 2bb152dd
<?php namespace Modules\User\Repositories\Sentry;
use Cartalyst\Sentry\Throttling\UserBannedException;
use Cartalyst\Sentry\Throttling\UserSuspendedException;
use Cartalyst\Sentry\Users\LoginRequiredException;
use Cartalyst\Sentry\Users\PasswordRequiredException;
use Cartalyst\Sentry\Users\UserNotActivatedException;
use Cartalyst\Sentry\Users\UserNotFoundException;
use Cartalyst\Sentry\Users\WrongPasswordException;
use Modules\Core\Contracts\Authentication;
use Cartalyst\Sentry\Facades\Laravel\Sentry;
......@@ -13,9 +20,40 @@ class SentryAuthentication implements Authentication
*/
public function login(array $credentials, $remember = false)
{
if (Sentry::authenticate($credentials, $remember)) {
try
{
Sentry::authenticate($credentials, $remember);
return false;
}
catch (LoginRequiredException $e)
{
return 'Login field is required.';
}
catch (PasswordRequiredException $e)
{
return 'Password field is required.';
}
catch (WrongPasswordException $e)
{
return 'Wrong password, try again.';
}
catch (UserNotFoundException $e)
{
return 'User was not found.';
}
catch (UserNotActivatedException $e)
{
return 'User is not activated.';
}
catch (UserSuspendedException $e)
{
return 'User is suspended.';
}
catch (UserBannedException $e)
{
return 'User is banned.';
}
return 'Invalid login or password.';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment