Skip to content

Commit

Permalink
Implement new method 'changePasswordWithoutOldPassword' in 'Auth'
Browse files Browse the repository at this point in the history
  • Loading branch information
ocram committed Aug 3, 2017
1 parent e4f8673 commit 1800525
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,26 @@ public function changePassword($oldPassword, $newPassword) {
}
}

/**
* Changes the currently signed-in user's password without requiring the old password for verification
*
* @param string $newPassword the new password that should be set
* @throws NotLoggedInException if the user is not currently signed in
* @throws InvalidPasswordException if the desired new password has been invalid
* @throws AuthError if an internal problem occurred (do *not* catch)
*/
public function changePasswordWithoutOldPassword($newPassword) {
if ($this->isLoggedIn()) {
$newPassword = self::validatePassword($newPassword);
$userId = $this->getUserId();
$this->updatePassword($userId, $newPassword);
$this->deleteRememberDirective($userId);
}
else {
throw new NotLoggedInException();
}
}

/**
* Updates the given user's password by setting it to the new specified password
*
Expand Down

0 comments on commit 1800525

Please sign in to comment.