Blackbook.Authentication

Handles core authentication “stuff” - verifying who the user is,resetting information etc.

Summary

Functions

The core “login” method that takes an email and password

Each user is granted a single token login at registration. This method uses that unique token to log them in

Returns a password reminder token the user can use to validate against and then reset their password. Expires in 24 hours

Each user has a random user key assigned to them at registration. This is a good candidate for use as a session key

Validates a password reset token by 1) making sure it exists and 2) making sure it isn’t expired. The user record is returned

Functions

authenticate_by_email_password(email, password)

The core “login” method that takes an email and password.

Examples

{:ok, user} = Blackbook.Authentication.authenticate_by_email_password 'test@test.com', 'password'
authenticate_by_token(token)

Each user is granted a single token login at registration. This method uses that unique token to log them in.

Examples

{:ok, user} = Blackbook.Authentication.authenticate_by_token 'BIGLONGTOKEN'
change_password(email, old_password, new_password)

Changes the user’s password.

Examples

{:ok, user} = Blackbook.Authentication.change_password 'test@test.com', 'password', 'new_password'
get_reminder_token(email)

Returns a password reminder token the user can use to validate against and then reset their password. Expires in 24 hours.

Examples

token = Blackbook.Authentication.get_reminder_token 'test@test.com'
get_user(key)

Each user has a random user key assigned to them at registration. This is a good candidate for use as a session key.

Examples

{:ok, user} = Blackbook.Authentication.get_user 'MY_USER_KEY'
validate_password_reset(token)

Validates a password reset token by 1) making sure it exists and 2) making sure it isn’t expired. The user record is returned.

Examples

{:ok, user} = Blackbook.Authentication.validate_password_reset 'test@test.com'