- Users\UserPassword
class Users \ UserPassword
Allows users to be logged in with emails and passwords.
Method Summary
Name | Description |
---|---|
addPassword(Connection $db, User $user, $password) | Add a password to the given account. |
changePassword(Connection $db, User $user, $password) | Change the given users' password. Removes all existing passwords and then adds a new password. |
completePasswordReset(Connection $db, $email, $secret, $new_password) | |
deletePasswords(Connection $db, User $user) | Delete all paswords for the given user. |
forgottenPassword(Connection $db, $email) | Create a forgotten password secret which is stored in the database. This will return a secret which must then be passed along with the mail to completePasswordReset() in order to reset the password. It is up to the application to send the appropriate email/etc. |
getPasswordUser(Connection $db, $email) | |
hash($password) | |
tryLogin(Connection $db, $email, $password) | Try logging in as a user with the given email and password. |
trySignup(Connection $db, $email, $password) |
static function addPassword(Connection $db, User $user, $password)
Add a password to the given account.
- Throws:
UserSignupException - if the user could not be signed up, with a reasonUserAlreadyExistsException - if the password already exists in the database
static function changePassword(Connection $db, User $user, $password)
Change the given users' password. Removes all existing passwords and then adds a new password.
- Throws:
UserPasswordException - if something went wrong
static function completePasswordReset(Connection $db, $email, $secret, $new_password)
- Throws:
UserPasswordException - if something went wrong
static function deletePasswords(Connection $db, User $user)
Delete all paswords for the given user.
static function forgottenPassword(Connection $db, $email)
Create a forgotten password secret which is stored in the database. This will return a secret which must then be passed along with the mail to completePasswordReset() in order to reset the password. It is up to the application to send the appropriate email/etc.
- Throws:
UserPasswordException - if something went wrong
static function getPasswordUser(Connection $db, $email)
- Throws:
UserPasswordException - if something went wrong
static function hash($password)
static function tryLogin(Connection $db, $email, $password)
Try logging in as a user with the given email and password.
- Returns:
a valid User- Throws:
UserAuthenticationException - if the user could not be logged in, with a reason
static function trySignup(Connection $db, $email, $password)
- Returns:
the created User- Throws:
UserSignupException - if the user could not be signed up, with a reasonUserAlreadyExistsException - if the user already exists in the database