public function login(Request $request, Auth $auth) : Redirection
 {
     $authorized = $auth->guard($this->guard)->attempt($request->only('email', 'password'));
     if ($authorized) {
         return redirect()->intended($this->redirectTo);
     }
     return back()->with('authError', 'Email ou senha incorretos.')->withInput($request->except('password'));
 }
示例#2
0
 public function authenticate(AuthRequest $request)
 {
     $data = $request->only('email', 'password');
     $user = (new User())->where('email', $data['email'])->first();
     if ($user->password === null) {
         // Был авторизован через соц сети, пароль не установлен
     }
     if (Auth::attempt($data, true)) {
         return redirect()->to('/');
     }
     return redirect()->back();
 }
 /**
  * @Post("api/auth/login", as="api.auth.login")
  *
  * @Middleware("guest")
  *
  * @param AuthRequest $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function login(AuthRequest $request)
 {
     $credentials = $request->only('email', 'password');
     try {
         if (!($token = JWTAuth::attempt($credentials))) {
             return $this->respondInvalidCredentials('Invalid Credentials');
         }
     } catch (JWTException $e) {
         return $this->respondTokenCreationFailed('Could Not Create Token');
     }
     $user = JWTAuth::toUser($token);
     if ($request->input('include') !== null) {
         $this->fractal->parseIncludes($request->input('include'));
     }
     return $this->fractal->item(['token' => $token, 'user' => $user], new AuthenticationTransformer());
 }
示例#4
0
 /**
  * Make a response for the case when the login fails
  *
  * @param AuthRequest $request
  * @return $this
  */
 protected function respondLoginFail(AuthRequest $request)
 {
     flash()->error(trans('auth.failedLogin'));
     return redirect(route('session.create'))->withInput($request->only('email', 'remember'));
 }