Example #1
0
 /**
  * @param UserRepositoryInterface $users
  * @param Hasher $hasher
  * @return mixed|string
  * @throws \Exception
  */
 public function handle(UserRepositoryInterface $users, hasher $hasher)
 {
     $user = $users->findUserByEmail($this->email);
     if ($user) {
         if (!$this->validToken($user)) {
             return 'invalid token';
         }
         if ($this->equalPasswords()) {
             $user->password = $hasher->make($this->password);
             $user->reset_token_id = null;
             $user->save();
             $this->token->delete();
             return $user;
         }
     }
 }
Example #2
0
 /**
  * @param $value
  * @return \Illuminate\Database\Eloquent\Model|null|static
  */
 public function findTokenByValue($value)
 {
     return $this->token->newQuery()->where('value', $value)->first();
 }