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


PHP Passwords\PasswordBroker类代码示例

本文整理汇总了PHP中Illuminate\Auth\Passwords\PasswordBroker的典型用法代码示例。如果您正苦于以下问题:PHP PasswordBroker类的具体用法?PHP PasswordBroker怎么用?PHP PasswordBroker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: postChange

 /**
  * Reset the given user's password.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postChange(Request $request)
 {
     $validator = Validator::make($request->all(), ['token' => 'required', 'old_passwd' => 'required', 'password' => 'required|confirmed'], [], ['old_passwd' => '原密码', 'password' => '新密码']);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     $auth_array = array('email' => Auth::user()->email, 'password' => Input::get('old_passwd'));
     if (Auth::validate($auth_array)) {
     } else {
         return redirect()->back()->withErrors("请输入正确的密码!");
     }
     $credentials = array('email' => Auth::user()->email, 'password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation'), 'token' => Input::get('token'));
     $response = $this->passwords->reset($credentials, function ($user, $password) {
         $user->password = bcrypt($password);
         $user->save();
         $this->auth->login($user);
     });
     switch ($response) {
         case PasswordBroker::PASSWORD_RESET:
             $array = array('email' => Auth::user()->email);
             $token = $this->passwords->getToken($array);
             UserManageLog::insertLog("修改密码", Auth::user()->id, Auth::user()->name, Auth::user()->email, Auth::user()->name . '(' . Auth::user()->email . ')', null, null, $request->ip());
             return view('auth.change_password')->withTips("密码修改成功!")->withToken($token);
         default:
             return redirect()->back()->withErrors(['email' => trans($response)]);
     }
 }
开发者ID:ChenPeiyuan,项目名称:student-infomation-manager,代码行数:33,代码来源:ChangePasswordController.php

示例2: postReset

 public function postReset(Request $request, PasswordBroker $broker)
 {
     $credentials = $request->only('email');
     Validator::make($credentials, ['email' => 'required|email']);
     $response = $broker->sendResetLink($credentials, function ($m) {
         $m->subject('Reset Password');
     });
     switch ($response) {
         case PasswordBroker::RESET_LINK_SENT:
             return response()->json('Password reset sent.');
         case PasswordBroker::INVALID_USER:
             return response()->json(trans($response))->setStatusCode(412, 'Invalid User');
     }
 }
开发者ID:fredlawl,项目名称:planebox-api,代码行数:14,代码来源:AuthController.php

示例3: postReset

 /**
  * Reset a users password
  * @param  AuthRequestInterface $request
  * @param  PasswordBroker       $passwords
  * @return Illuminate\Http\Response
  */
 public function postReset(AuthRequestInterface $request, PasswordBroker $passwords)
 {
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = $passwords->reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case PasswordBroker::PASSWORD_RESET:
             return $this->passwordWasReset($request);
             break;
         default:
             return $this->passwordWasNotReset($request, $response);
             break;
     }
 }
开发者ID:ruysu,项目名称:laravel-core,代码行数:21,代码来源:ResetsPasswords.php

示例4: getUser

 /**
  * Get the user for the given credentials.
  *
  * @param array $credentials
  * @return \Illuminate\Contracts\Auth\CanResetPassword 
  * @throws \UnexpectedValueException
  * @static 
  */
 public static function getUser($credentials)
 {
     return \Illuminate\Auth\Passwords\PasswordBroker::getUser($credentials);
 }
开发者ID:tvad911,项目名称:biquyetmuasam.com,代码行数:12,代码来源:_ide_helper.php

示例5: registerPasswordBroker

 /**
  * Register the password broker instance.
  *
  * @return void
  */
 protected function registerPasswordBroker()
 {
     $this->app->singleton('auth.password', function ($app) {
         // The password token repository is responsible for storing the email addresses
         // and password reset tokens. It will be used to verify the tokens are valid
         // for the given e-mail addresses. We will resolve an implementation here.
         $tokens = $app['auth.password.tokens'];
         $users = $app['auth']->driver()->getProvider();
         $view = $app['config']['auth.password.email'];
         // The password broker uses a token repository to validate tokens and send user
         // password e-mails, as well as validating that password reset process as an
         // aggregate service of sorts providing a convenient interface for resets.
         $broker = new PasswordBroker($tokens, $users, $app['mailer'], $view);
         // register validator for password
         $broker->validator(function ($credentials) {
             try {
                 return app('xe.user')->validatePassword($credentials['password']);
             } catch (\Exception $e) {
                 return false;
             }
         });
         return $broker;
     });
 }
开发者ID:xpressengine,项目名称:xpressengine,代码行数:29,代码来源:UserServiceProvider.php

示例6: resetPassword

 /**
  * Process a password reset request. This is the last step in the reset process
  *
  * @param $credentials
  * @return mixed|string
  */
 public function resetPassword($credentials)
 {
     $status = $this->passwordBroker->reset($credentials, function ($user, $password) {
         $user->password = app('hash')->make($password);
         if ($user->save()) {
             // auto login the user
             auth()->login($user);
         }
     });
     return $status;
 }
开发者ID:muhamadsyahril,项目名称:ecommerce-1,代码行数:17,代码来源:ResetPasswords.php

示例7: postReset

 public function postReset()
 {
     $credentials = $this->request->only('email', 'password', 'password_confirmation', 'token');
     $response = $this->password->reset($credentials, function ($user, $password) {
         $user->password = $this->hasher->make($password);
         $user->save();
     });
     switch ($response) {
         case $this->password->INVALID_PASSWORD:
         case $this->password->INVALID_TOKEN:
         case $this->password->INVALID_USER:
             return $this->redirector->back()->with('error', $this->translator->get($response));
         case $this->password->PASSWORD_RESET:
             return $this->redirector->to('/');
     }
 }
开发者ID:PhonemeCms,项目名称:cms,代码行数:16,代码来源:RemindersController.php


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