Documentation
¶
Index ¶
- Constants
- func Create(ctx context.Context, db sqlx.ExtContext, token Token) error
- func DeleteByUser(ctx context.Context, db sqlx.ExtContext, userID string, scope string) error
- func HandleActivation(db *sqlx.DB, session *scs.SessionManager) web.Handler
- func HandleRecovery(db *sqlx.DB) web.Handler
- func HandleToken(db *sqlx.DB, mailer Mailer, timeout time.Duration, bg *background.Background) web.Handler
- type Mailer
- type Token
Constants ¶
const ( ActivationToken = "activation" RecoveryToken = "recovery" )
Variables ¶
This section is empty.
Functions ¶
func DeleteByUser ¶
DeleteByUser drops the token associated to the passed user with a specific scope, if any.
func HandleActivation ¶
HandleActivation validates the passed token and, if correct, it activates the user.
func HandleRecovery ¶
HandleRecovery validates the passed token and, if correct, changes the user's password with the one provided.
func HandleToken ¶
func HandleToken(db *sqlx.DB, mailer Mailer, timeout time.Duration, bg *background.Background) web.Handler
HandleToken is used to send specific tokens to users via email. A valid scope must be provided by users, together with their email. It doesn't require a user to be logged in, because users who need tokens will probably not be able to login at all. This function leverages a rate limiter to avoid too many emails.
Types ¶
type Mailer ¶
type Mailer interface { SendActivationToken(token string, to string) error SendRecoveryToken(token string, to string) error }
Mailer should be able to send emails to users for handling their activation and their password recovery.