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


PHP Auth::validate方法代码示例

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


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

示例1: validate

 /**
  * @param $credentials
  * @throws ValidationFailed
  */
 public function validate($credentials)
 {
     $valid = Auth::validate($credentials);
     if (!$valid) {
         throw new ValidationFailed();
     }
 }
开发者ID:RobbieBakker,项目名称:laravelstuff,代码行数:11,代码来源:User.php

示例2: login

 /**
  * @return Redirect
  */
 public function login()
 {
     $rules = array('email' => 'required', 'password' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return redirect('/')->withErrors($validator);
     } else {
         $user = array('email' => Input::get('email'), 'password' => Input::get('password'));
         if (Auth::validate($user)) {
             if (Auth::attempt($user)) {
                 // Grab Authenticated User's Data Once
                 $user_data = Auth::user();
                 Session::put('user_id', $user_data->id);
                 Session::put('name', $user_data->name);
                 Session::put('email_id', $user_data->email);
                 return redirect::to('settings');
             }
         } else {
             /*Session::flash('message','Login Failed');
               return redirect('auth/login');*/
             return Redirect::back()->withInput()->withErrors('That Email/password does not exist.');
         }
     }
     /* $email = Input::get('email');
             $password = Input::get('password');
     
             if (Auth::attempt(['email' => $email, 'password' => $password]))
             {
                 return Redirect::intended('/settings/index');
             }
     
             return Redirect::back()
                 ->withInput()
                 ->withErrors('That Email/password combo does not exist.');*/
 }
开发者ID:kanagaraj1305,项目名称:sample-login-in-laravel-5,代码行数:38,代码来源:LoginController.php

示例3: verifyByDocumentation

 public function verifyByDocumentation($username, $password)
 {
     if (Auth::validate(['email' => $username, 'password' => $password])) {
         $user = \App\User::where('email', $username)->first();
         return $user->id;
     } else {
         return false;
     }
 }
开发者ID:phcarvalho10,项目名称:manager,代码行数:9,代码来源:Verifier.php

示例4: verify

 public function verify($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     $valid = Auth::validate($credentials);
     if ($valid) {
         return Auth::getProvider()->retrieveByCredentials($credentials)->id;
     }
     return false;
 }
开发者ID:HOFB,项目名称:HOFB,代码行数:9,代码来源:PasswordVerify.php

示例5: update_password

 public function update_password($username, PasswordChangeRequest $request)
 {
     if (Auth::validate(['phone' => Auth::user()->phone, 'password' => $request->input('old_password')])) {
         Auth::user()->password = bcrypt($request->input('password'));
         Auth::user()->save();
         return redirect()->back()->with('success', 'Password updated successfully');
     } else {
         return redirect()->back()->with('error', 'Current password do not match with one in our record!');
     }
 }
开发者ID:soarmorrow,项目名称:grabage-collector,代码行数:10,代码来源:AccountController.php

示例6: doLogin

 public function doLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('username' => 'required|min:5', 'password' => 'required|min:6');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->withErrors($validator)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $userdata = array('username' => Input::get('username'), 'password' => Input::get('password'));
         // attempt to do the login
         if (Auth::validate($userdata)) {
             //  Valid Login
             $valid_login = true;
             //  Get User
             $user = UserItem::findUser($userdata["username"]);
             //  Check if User Disabled
             if (!$user->isEnabled()) {
                 return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.account_disabled"));
             }
             //  Trigger Login Event & Validate
             mergeEventFireResponse(true, Event::fire('user.login_validate', array($user, &$valid_login)));
             //  Check Valid
             if ($valid_login) {
                 //  Do Login
                 Auth::login($user);
                 //  Add Login Log
                 LoginLogItem::addLog($user, true);
                 //  Trigger Valid Login Event
                 Event::fire('user.valid_login', array($user));
                 // validation successful!
                 return Redirect::intended(URL::route(UserItem::dashboardRoute()))->with(FLASH_MSG_INFO, trans("auth-module::message.success_login"));
             } else {
                 //  Add Login Log
                 LoginLogItem::addLog($user, false);
                 //  Trigger Invalid Login Event
                 Event::fire('user.invalid_login', array($userdata['username']));
                 // validation not successful, send back to form
                 return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.invalid_login"))->withInput(Input::except('password'));
             }
         } else {
             //  Add Login Log
             LoginLogItem::addLogUsername($userdata["username"], false);
             //  Trigger Invalid Login Event
             Event::fire('user.invalid_login', array(Input::get('username')));
             // validation not successful, send back to form
             return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.invalid_login"))->withInput(Input::except('password'));
         }
     }
 }
开发者ID:developeryamhi,项目名称:laravel-admin,代码行数:53,代码来源:AuthController.php

示例7: verify

 public function verify($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     if (Auth::validate($credentials)) {
         $user = \CodeProject\Entities\User::where('email', $username)->first();
         return $user->id;
     }
     /*      if (Auth::once($credentials)) {
               return Auth::user()->id;
           }*/
     return false;
 }
开发者ID:vilmarspies,项目名称:codeproject-curso,代码行数:12,代码来源:Verifier.php

示例8: postLogin

 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin()
 {
     $loginData = Binput::only(['email', 'password']);
     // Validate login credentials.
     if (Auth::validate($loginData)) {
         // Log the user in for one request.
         Auth::once($loginData);
         // We probably want to add support for "Remember me" here.
         Auth::attempt($loginData);
         return Redirect::intended('dashboard');
     }
     return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
 }
开发者ID:xiuchanghu,项目名称:Gitamin,代码行数:18,代码来源:AuthController.php

示例9: postReset

 /**
  * Reset the current user's password.
  * @return Redirect
  */
 public function postReset()
 {
     $current_user = Auth::user();
     if (!Auth::validate(array('username' => Auth::user()->username, 'password' => Input::get('current_password')))) {
         return Redirect::back()->with('flash_error', 'Your current password does not match, please <a href="#password"> try again</a>!');
     }
     $validator = Validator::make(array('new_password' => Input::get('new_password'), 'new_password_confirmation' => Input::get('new_password_conf')), array('new_password' => 'required|min:5|confirmed'));
     if ($validator->passes()) {
         $current_user->password = Hash::make(Input::get('new_password'));
         $current_user->save();
         return Redirect::back()->with('flash_success', 'Your password has been updated successfully!');
     }
     return Redirect::back()->with('flash_error', 'Your new passwords do not match or your new password does not meet the minimum length five characters, please <a href="#password"> try again</a>!');
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:18,代码来源:PasswordController.php

示例10: attemptToSignIn

 /**
  * @param array $data
  * @param bool $rememberMe
  * @param bool $login
  *
  * @return User|false
  */
 public function attemptToSignIn(array $data, $rememberMe = false, $login = false)
 {
     if (!Auth::validate(array_only($data, ['email', 'password']))) {
         Flash::error(trans('ahk_messages.credentials_mismatch'));
         return false;
     }
     $user = $this->findByEmail($data['email']);
     if (!$user->verified) {
         Flash::error(trans('ahk_messages.please_validate_your_email_first'));
         return false;
     }
     Auth::login($user);
     return $user;
 }
开发者ID:ahk-ch,项目名称:chamb.net,代码行数:21,代码来源:DbUserRepository.php

示例11: loginPost

 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function loginPost()
 {
     $loginData = Request::only(['login', 'password']);
     // Login with username or email.
     $loginKey = Str::contains($loginData['login'], '@') ? 'email' : 'username';
     $loginData[$loginKey] = array_pull($loginData, 'login');
     // Validate login credentials.
     if (Auth::validate($loginData)) {
         // Log the user in for one request.
         Auth::once($loginData);
         // We probably want to add support for "Remember me" here.
         Auth::attempt($loginData);
         //return Redirect::intended('/')
         return Redirect::home()->withSuccess(trans('gitamin.signin.success'));
     }
     return Redirect::route('auth.login')->withInput(Request::except('password'))->withError(trans('gitamin.signin.invalid'));
 }
开发者ID:xiaobailc,项目名称:Gitamin,代码行数:22,代码来源:AuthController.php

示例12: changePassword

 public function changePassword(Request $request)
 {
     $validator = Validator::make($request->all(), ['current_password' => 'required', 'password' => 'required|confirmed|min:6']);
     if ($validator->fails()) {
         return redirect('/admin/changePassword')->with('errors', $validator->errors()->all());
     } else {
         $user = Auth::user();
         $credentials = ['email' => $user->email, 'password' => $request->get('current_password')];
         $valid = Auth::validate($credentials);
         if ($valid) {
             $user->password = bcrypt($request->get('password'));
             $user->save();
             $request->session()->flash("notif", "Password successfully changed!");
             return redirect('/profile');
         }
         return redirect('/admin/changePassword')->with('errors', ['Input correct current password']);
     }
 }
开发者ID:arjayads,项目名称:all-star,代码行数:18,代码来源:HomeController.php

示例13: persist

 /**
  * Persist the changes.
  *
  * @param User $user
  *
  * @throws InvalidPasswordException
  * @throws UnableToChangePasswordException
  *
  * @return bool
  */
 public function persist(User $user)
 {
     $credentials['password'] = $this->input('current_password');
     $credentials['email'] = $user->email;
     if (!Auth::validate($credentials)) {
         throw new InvalidPasswordException();
     }
     if ($user->from_ad) {
         // If the user is from active directory, we won't
         // allow them to change their password.
         throw new UnableToChangePasswordException();
     }
     // Change the users password.
     $user->password = $this->input('password');
     if (!$user->save()) {
         throw new UnableToChangePasswordException();
     }
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:28,代码来源:PasswordRequest.php

示例14: ChangePassword

 public function ChangePassword(ChangePassRequest $request)
 {
     if (Auth::check()) {
         $customer_data = ["email" => Auth::user()->email, "password" => $request->password_old];
         /*kiem tra mat khau cu*/
         if (Auth::validate($customer_data)) {
             //dung mat khau
             $customer = customer::find(Auth::user()->id);
             $customer->password = Hash::make($request->password);
             $customer->save();
             Auth::logout();
             return redirect()->route("login");
         } else {
             return redirect()->route("thongtin.template")->with("result", "Mật khẩu không chính xác");
         }
     } else {
         return redirect()->route("login");
     }
 }
开发者ID:thiennhan2310,项目名称:maimallshop,代码行数:19,代码来源:CustomerController.php

示例15: postLogin

 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin()
 {
     $loginData = Binput::only(['email', 'password']);
     // Validate login credentials.
     if (Auth::validate($loginData)) {
         // Log the user in for one request.
         Auth::once($loginData);
         // Do we have Two Factor Auth enabled?
         if (Auth::user()->hasTwoFactor) {
             // Temporarily store the user.
             Session::put('2fa_id', Auth::user()->id);
             return Redirect::route('auth.two-factor');
         }
         // We probably want to add support for "Remember me" here.
         Auth::attempt($loginData);
         return Redirect::intended('dashboard');
     }
     return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
 }
开发者ID:guduchango,项目名称:Cachet,代码行数:24,代码来源:AuthController.php


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