Documentation ¶
Index ¶
- Constants
- type Repository
- type Store
- func (s *Store) CleanPasswordResets() error
- func (s *Store) Login(email, password string) (domain.User, error)
- func (s *Store) Logout(token string) (int, error)
- func (s *Store) ResetPassword(token, password string) error
- func (s *Store) SendResetPassword(email string) (domain.UserPart, string, error)
- func (s *Store) VerifyPasswordToken(token string) (domain.PasswordReset, error)
Constants ¶
const ( // The database table name for password resets. PasswordTableName = "password_resets" // ErrLoginMsg is returned by login when // authentication failed. ErrLoginMsg = "These credentials don't match our records." )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { Login(email, password string) (domain.User, error) Logout(token string) (int, error) ResetPassword(token, password string) error SendResetPassword(email string) (domain.UserPart, string, error) VerifyPasswordToken(token string) (domain.PasswordReset, error) CleanPasswordResets() error }
Repository defines methods for auth to interact with the database.
type Store ¶
Store defines the data layer for auth.
func (*Store) CleanPasswordResets ¶
CleanPasswordResets
Verify the token is valid from the password resets table Returns errors.INTERNAL if the SQL query was invalid.
func (*Store) Login ¶
Login
Authenticate compares the email & password for a match in the DB. Returns errors.NOTFOUND if the user is not found.
func (*Store) Logout ¶
Logout
Logout checks to see if see if the the token is valid & then proceeds to create a new token and returns the user ID. Returns errors.NOTFOUND if the user was not found by the given token. Returns errors.INTERNAL if the SQL query was invalid.
func (*Store) ResetPassword ¶
ResetPassword
Obtains the password reset information from the table and creates a new hash, it then updates the user table with the new details and removes the temporary entry in the PasswordTableName table.
Returns errors.NOTFOUND if the user was not found by the given token. Returns errors.INTERNAL if the SQL query was invalid, unable to create a new password or delete from the password resets table.
func (*Store) SendResetPassword ¶
SendResetPassword
Obtains the user by email and generates a new email token. A temporary record is inserted to the password resets table and an email is sent to the user by the reset passwords event. passwords event. Returns errors.NOTFOUND if the user was not found by the given email. Returns errors.INTERNAL if the SQL query was invalid.
func (*Store) VerifyPasswordToken ¶
func (s *Store) VerifyPasswordToken(token string) (domain.PasswordReset, error)
VerifyPasswordToken
Checks to see if the token is valid from the password resets table. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the user was not found by the given token.