예제 #1
0
 /**
  * Set a custom password validator.
  *
  * @param \Closure $callback
  * @return void 
  * @static 
  */
 public static function validator($callback)
 {
     \Illuminate\Auth\Passwords\PasswordBroker::validator($callback);
 }
 /**
  * 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;
     });
 }