Ejemplo n.º 1
0
 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @return Response
  */
 public function postLogin(LoginRequest $request, MaxValueDelay $maxValueDelay)
 {
     $logValue = $request->input('log');
     if ($maxValueDelay->check($logValue)) {
         return redirect('/auth/login')->with('error', trans('front/login.maxattempt'));
     }
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if ($this->auth->attempt($credentials, $request->has('memory'))) {
         return redirect('/');
     }
     $maxValueDelay->increment($logValue);
     return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('email'));
 }
Ejemplo n.º 2
0
 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @param  App\Services\MaxValueDelay  $maxValueDelay
  * @param  Guard  $auth
  * @return Response
  */
 public function postLogin(LoginRequest $request, MaxValueDelay $maxValueDelay, Guard $auth)
 {
     $logValue = $request->input('log');
     if ($maxValueDelay->check($logValue)) {
         return redirect('/auth/login')->with('error', trans('front/login.maxattempt'));
     }
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         $maxValueDelay->increment($logValue);
         return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect('/');
     }
     $request->session()->put('user_id', $user->id);
     return redirect('/auth/login')->with('error', trans('front/verify.again'));
 }