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


PHP Auth::validate方法代码示例

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


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

示例1: postLogin

 function postLogin(Request $request)
 {
     $email = $request->input('email');
     $password = $request->input('password');
     $userdata = array('email' => $email, 'password' => Hash::make($password));
     //        return Redirect::to('/basic');
     if (Auth::validate($userdata)) {
         if (Auth::attempt($userdata)) {
             return Redirect::to('/basic');
         }
     } else {
         // if any error send back with message.
         Session::flash('error', 'Something went wrong');
         return Redirect::to('login');
     }
 }
开发者ID:leloulight,项目名称:lakon,代码行数:16,代码来源:AuthController.php

示例2: postChangePassword

 public function postChangePassword(Request $request)
 {
     if (!\Auth::validate(['email' => \Auth::user()->email, 'password' => $request->input('old_password')])) {
         \Alert::error(trans('auth.wrong_password'))->flash();
         return redirect()->back();
     }
     // validation
     $validator = \Validator::make($request->all(), ['old_password' => 'required', 'new_password' => 'required|confirmed|min:6']);
     if ($validator->fails()) {
         // The given data did not pass validation
         return redirect()->back()->withInput()->withErrors($validator->errors());
     }
     // change the password
     $user = User::findOrFail(\Auth::user()->id);
     $user->password = $request->input('new_password');
     $user->save();
     // set a success/error message
     \Alert::success(trans('auth.password_updated'))->flash();
     // redirect to the change password page
     return redirect()->back();
 }
开发者ID:tahirghori,项目名称:dick,代码行数:21,代码来源:UserController.php

示例3: login

 public function login()
 {
     // Getting all post data
     $data = \Input::all();
     // Applying validation rules.
     $rules = array('email' => 'required|email', 'password' => 'required|min:6');
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         // If validation falis redirect back to login.
         return \Redirect::to('admin/login')->withInput(\Input::except('password'))->withErrors($validator);
     } else {
         $userdata = array('email' => \Input::get('email'), 'password' => \Input::get('password'));
         // doing login.
         if (\Auth::validate($userdata)) {
             if (\Auth::attempt($userdata)) {
                 return \Redirect::intended('/categories');
             }
         } else {
             // if any error send back with message.
             \Session::flash('error', 'Something went wrong');
             return \Redirect::to('admin/login');
         }
     }
 }
开发者ID:devchd,项目名称:metronic,代码行数:24,代码来源:AuthController.php


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