当前位置: 首页>>代码示例>>PHP>>正文


PHP Guard::validate方法代码示例

本文整理汇总了PHP中Illuminate\Contracts\Auth\Guard::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::validate方法的具体用法?PHP Guard::validate怎么用?PHP Guard::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Contracts\Auth\Guard的用法示例。


在下文中一共展示了Guard::validate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postIndex

 /**
  * Opens the password reset form.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postIndex(Request $request)
 {
     $validator = $this->validate($request, ['password' => "required", 'password_new' => "required|confirmed|min:4"]);
     $credentials = $request->only('password', 'password_new');
     $user = $this->auth->user();
     if ($this->auth->validate(['username' => $user->username, 'password' => $credentials['password']])) {
         $user->password = bcrypt($credentials['password_new']);
         $user->save();
         $this->auth->login($user);
         return $this->view(static::VIEW_CHANGE)->withStatus(trans('custom.success.password_new'));
     }
     return $this->view(static::VIEW_CHANGE)->withErrors(['username' => trans('custom.validate.password_old')]);
 }
开发者ID:nitogel,项目名称:infinity-next,代码行数:19,代码来源:PasswordController.php

示例2: postLogin

 /**
  * 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, Guard $auth)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return redirect('/auth/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('log'));
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $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'));
 }
开发者ID:thaida,项目名称:CMS,代码行数:37,代码来源:AuthController.php

示例3: postLogin

 /**
  * Handle request login
  * @param  LoginRequest $request 
  * @param  Guard        $auth    
  * @return Response              
  */
 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         $message = "内容を入力してください。";
         $alertClass = "alert-danger";
         return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         $message = "内容を入力してください。";
         $alertClass = "alert-danger";
         return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
     }
     $user = $auth->getLastAttempted();
     if ($user) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, false);
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect(route('top'));
     }
     $request->session()->put('user_id', $user->id);
     $message = "内容を入力してください。";
     $alertClass = "alert-danger";
     return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
 }
开发者ID:doankhoi,项目名称:TravelResearch,代码行数:41,代码来源:AuthController.php

示例4: postLogin

 /**
  * Login action.
  *
  * @param LoginRequest $request
  * @param Guard $auth
  * @return \Illuminate\Http\JsonResponse
  */
 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $input = $request->all();
     // Filter login with email or name.
     $logAccess = filter_var($input['log'], FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
     // Throttle
     $throttle = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttle && $this->hasTooManyLoginAttempts($request)) {
         return response()->json(['return' => false, 'value' => 'Too many attempts.']);
     }
     $credentials = [$logAccess => $input['log'], 'password' => $input['password']];
     if (!$auth->validate($credentials)) {
         if ($throttle) {
             $this->incrementLoginAttempts($request);
         }
         return response()->json(['return' => false, 'value' => 'Login failed, One more try.']);
     }
     $user = $auth->getLastAttempted();
     if ($user) {
         if ($throttle) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $input['remember']);
         session()->put('user_name', $user->name);
         session()->put('user_email', $user->email);
         return response()->json(['return' => true, 'value' => url('/dashboard')]);
     }
     return response()->json(['return' => false, 'value' => 'Login failed, One more try.']);
 }
开发者ID:forehalo,项目名称:materialize-blog,代码行数:36,代码来源:AuthController.php

示例5: postLogin

 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $email = $request->input('email');
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return redirect('/admin/login')->with('error', '세션이 만료되었습니다')->withInput($request->only('email'));
     }
     $credentials = ['email' => $email, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return redirect('/admin/login')->with('error', '사용자를 찾을 수 없습니다')->withInput($request->only('email'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect('/admin/dashboard');
     }
     $request->session()->put('user_id', $user->id);
     return redirect('/admin/login')->with('error', '사용자를 다시 인증하세요');
 }
开发者ID:neo1125,项目名称:petplus_server,代码行数:28,代码来源:LoginController.php

示例6: postLogin

 /**
  * 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(MaxValueDelay $maxValueDelay, Guard $auth)
 {
     //Se obtiene los datos que llegan del formulario
     $request = Request::all();
     //Se almacena en una variable el campo de email-username
     $logValue = $request['log'];
     //Se verifica que no se encuentre en cache - maxValueDelay se encuentra en servicios
     if ($maxValueDelay->check($logValue)) {
         return redirect('/auth/login')->with('error', trans('front/login.maxattempt'));
     }
     //Valida que valor ingresaron, email - username
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     //Se almacenan en un objeto
     $credentials = [$logAccess => $logValue, 'password' => $request['password']];
     if (!$auth->validate($credentials)) {
         //Guarda en cache el intento erroneo
         $maxValueDelay->increment($logValue);
         return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request);
     }
     //Obtiene el ultimo intento realizado
     $user = $auth->getLastAttempted();
     //Si el ultimo intento que realizo es 1 ingresa
     //Valida que si ya esta logueado no ingrese al loguin
     if ($user->confirmed) {
         $c = isset($request['memory']) ? true : false;
         $auth->login($user, $c);
         if (Request::session()->has('user_id')) {
             Request::session()->forget('user_id');
         }
         return redirect('/home');
     }
     Request::session()->put('user_id', $user->id);
     return redirect('/auth/login')->with('error', trans('front/verify.again'));
 }
开发者ID:jhuhandha,项目名称:inhousel,代码行数:42,代码来源:AuthController.php

示例7: postLogin

 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         $message = "Đăng nhập vượt quá số lần quy định.";
         $alertClass = "alert-danger";
         return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         $message = "Tên đăng nhập hoặc mật khẩu không hợp lệ.";
         $alertClass = "alert-danger";
         return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect(route('website.index'));
     }
     $request->session()->put('user_id', $user->id);
     $message = "Tên đăng nhập hoặc mật khẩu không hợp lệ.";
     $alertClass = "alert-danger";
     return redirect()->back()->with(compact('message', 'alertClass'))->withInput();
 }
开发者ID:doankhoi,项目名称:Application,代码行数:35,代码来源:AuthController.php

示例8: postLogin

 /**
  * 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, Guard $auth, ServiciosOperadorRepository $gestion)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return redirect('/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('log'));
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return redirect('/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed || $user->valid) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         $request->session()->put('user_name', $user->username);
         $email = $auth->user()->email;
         $nombre = $auth->user()->user_name;
         /* Busca si ya tiene servicios activos o no */
         //logica que comprueba si el usuario tiene servicios para ser modificados
         //caso contrario ingresa nuevos serviciosS
         $listServicios = $gestion->getServiciosidUsuario($user->id);
         if ($listServicios) {
             $data['id_usuario_op'] = $listServicios[0]->id_usuario_op;
             $request->session()->put('operador_id', $data['id_usuario_op']);
             //        $view = view('Registro.catalogoServicio', compact('data', 'listServicios'));
             $request->session()->put('tip_oper', $listServicios[0]->id_tipo_operador);
             return redirect('/detalleServicios')->with('user', $user->id);
             // return ($view);
         } else {
             return redirect('/myProfileOp')->with('user', $user->id);
         }
     } else {
         /* --------------------------------- */
         return redirect('/login')->with('error', trans('front/verify.again'))->withInput($request->only('log'));
     }
 }
开发者ID:adrianicn,项目名称:IguanaTrip,代码行数:54,代码来源:AuthController.php

示例9: postEBLogin

 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @param  Guard  $auth
  * @return Response
  */
 public function postEBLogin(LoginRequest $request, Guard $auth)
 {
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         if ($request->ajax()) {
             return response(trans('front/login.maxattempt'), 422)->header('Content-Type', 'application/json');
         } else {
             return redirect('/auth/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('username'));
         }
     }
     $credentials = $request->only('username', 'password');
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             // 				$request->merge(['remember'=>true]);
             $this->incrementLoginAttempts($request);
         }
         $user = User::where('username', '=', $request->input('username'))->first();
         if ($user === null) {
             // user doesn't exist
             if ($request->ajax()) {
                 return response('Wrong username', 422)->header('Content-Type', 'application/json');
             } else {
                 return redirect('/auth/login')->with('error', 'Wrong username')->withInput();
             }
         } else {
             // Wrong username
             if ($request->ajax()) {
                 return response('Wrong password', 422)->header('Content-Type', 'application/json');
             } else {
                 return redirect('/auth/login')->with('error', 'Wrong password')->withInput();
             }
         }
     }
     $user = $auth->getLastAttempted();
     // 		if($user->confirmed) {
     if ($throttles) {
         $this->clearLoginAttempts($request);
     }
     $auth->login($user, $request->has('memory'));
     if ($request->session()->has('user_id')) {
         $request->session()->forget('user_id');
     }
     return response(['msg' => 'ok'], 200)->header('Content-Type', 'application/json');
     // 		}
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:52,代码来源:AuthController.php

示例10: postLogin

 /**
  * 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'));
 }
开发者ID:nitsmax,项目名称:els,代码行数:31,代码来源:AuthController.php


注:本文中的Illuminate\Contracts\Auth\Guard::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。