Пример #1
0
 public static function password_grant($email, $password)
 {
     $user_type = \Request::input('user_type');
     if (!in_array($user_type, ['admin', 'user'])) {
         throw new BadRequestHttpException();
     }
     switch ($user_type) {
         case 'admin':
             $user = Admin::attempt($email, $password);
             break;
         default:
             $user = User::attempt($email, $password);
             break;
     }
     return $user ? "{$user_type}:{$user->id}" : false;
 }