Пример #1
0
 /**
  * Reset a password when a request exists.
  *
  * @return boolean
  */
 public static function reset(Account $account, $new_pass)
 {
     if (!$account->id() || !$account->isOperational() || $new_pass === null || $new_pass === '') {
         return false;
     }
     // Get request by account id.
     $request = self::where('_account_id', '=', $account->id())->first();
     if (!$request instanceof PasswordResetRequest || !$request->isActive()) {
         return false;
     } else {
         $account->changePassword($new_pass);
         // Mark all prior requests as "used"
         self::where('_account_id', '=', $account->id())->update(['used' => true]);
         return static::sendResetNotification($account->getActiveEmail());
     }
 }