Laravel Войти через Sentry

Я новичок в laravel и пытаюсь реализовать функцию входа в систему с часовым, где у меня есть две группы в базе данных, группа «администратор» и «пользователь», где каждая группа будет перенаправлена ​​на их уважаемые взгляды, но это дает мне следующая ошибка

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Вызов функции-члена inGroup () для необъекта

Откройте: C: \ wamp \ www \ library \ app \ controllers \ UserController.php

Область указывает на эту область кода

  {
echo 'User is suspended.';
}
catch (Cartalyst\Sentry\Throttling\UserBannedException $e)
{
echo 'User is banned.';
}
$user = Sentry::getUser();
$admin = Sentry::findGroupByName('admin');
$users = Sentry::findGroupByName('user');

if ($user->inGroup($admin)) return Redirect::intended('admin');
elseif ($user->inGroup($users)) return Redirect::intended('user');

Вот мой полный код для входа в систему

    public function postLogin(){
try
{
// Login credentials
$credentials = array(
'email'    => Input::get('email'),
'password' => Input::get('password'),
);

// Authenticate the user
Sentry::authenticate($credentials, false);
}
catch (Cartalyst\Sentry\Users\LoginRequiredException $e)
{
echo 'Login field is required.';
}
catch (Cartalyst\Sentry\Users\PasswordRequiredException $e)
{
echo 'Password field is required.';
}
catch (Cartalyst\Sentry\Users\WrongPasswordException $e)
{
echo 'Wrong password, try again.';
}
catch (Cartalyst\Sentry\Users\UserNotFoundException $e)
{
echo 'User was not found.';
}
catch (Cartalyst\Sentry\Users\UserNotActivatedException $e)
{
echo 'User is not activated.';
}

catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e)
{
echo 'User is suspended.';
}
catch (Cartalyst\Sentry\Throttling\UserBannedException $e)
{
echo 'User is banned.';
}
$user = Sentry::getUser();
$admin = Sentry::findGroupByName('admin');
$users = Sentry::findGroupByName('user');

if ($user->inGroup($admin)) return Redirect::intended('admin');
elseif ($user->inGroup($users)) return Redirect::intended('user');

}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector