Commit 0318671d authored by Nicolas Widart's avatar Nicolas Widart

Merge commit 'cf4bb7d7'

* commit 'cf4bb7d7':
  Squashed 'Modules/User/' changes from a0751eb..d4e1225
parents 62e6e9ec cf4bb7d7
......@@ -16,4 +16,9 @@ class SentryUser extends User
];
protected $presenter = 'Modules\User\Presenters\UserPresenter';
public function groups()
{
return $this->belongsToMany(static::$groupModel, static::$userGroupsPivot, 'user_id');
}
}
<?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.';
}
......@@ -110,6 +148,9 @@ class SentryAuthentication implements Authentication
*/
public function check()
{
return Sentry::check();
if (Sentry::check()) {
return Sentry::getUser();
}
return false;
}
}
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