Documentation ¶
Overview ¶
Package confirm implements confirmation of user registration via e-mail
Index ¶
- Constants
- func GenerateConfirmCreds() (selector, verifier, token string, err error)
- func Middleware(ab *authboss.Authboss) func(http.Handler) http.Handler
- type Confirm
- func (c *Confirm) Get(w http.ResponseWriter, r *http.Request) error
- func (c *Confirm) Init(ab *authboss.Authboss) (err error)
- func (c *Confirm) PreventAuth(w http.ResponseWriter, r *http.Request, handled bool) (bool, error)
- func (c *Confirm) SendConfirmEmail(ctx context.Context, to, token string)
- func (c *Confirm) StartConfirmation(ctx context.Context, user authboss.ConfirmableUser, sendEmail bool) error
- func (c *Confirm) StartConfirmationWeb(w http.ResponseWriter, r *http.Request, handled bool) (bool, error)
Constants ¶
const ( // PageConfirm is only really used for the BodyReader PageConfirm = "confirm" // EmailConfirmHTML is the name of the html template for e-mails EmailConfirmHTML = "confirm_html" // EmailConfirmTxt is the name of the text template for e-mails EmailConfirmTxt = "confirm_txt" // FormValueConfirm is the name of the form value for FormValueConfirm = "cnf" // DataConfirmURL is the name of the e-mail template variable // that gives the url to send to the user for confirmation. DataConfirmURL = "url" )
Variables ¶
This section is empty.
Functions ¶
func GenerateConfirmCreds ¶
GenerateConfirmCreds generates pieces needed for user confirmy selector: hash of the first half of a 64 byte value (to be stored in the database and used in SELECT query) verifier: hash of the second half of a 64 byte value (to be stored in database but never used in SELECT query) token: the user-facing base64 encoded selector+verifier
func Middleware ¶
Middleware ensures that a user is confirmed, or else it will intercept the request and send them to the confirm page, this will load the user if he's not been loaded yet from the session.
Panics if the user was not able to be loaded in order to allow a panic handler to show a nice error page, also panics if it failed to redirect for whatever reason.
Types ¶
type Confirm ¶
Confirm module
func (*Confirm) PreventAuth ¶
PreventAuth stops the EventAuth from succeeding when a user is not confirmed This relies on the fact that the context holds the user at this point in time loaded by the auth module (or something else).
func (*Confirm) SendConfirmEmail ¶
SendConfirmEmail sends a confirmation e-mail to a user
func (*Confirm) StartConfirmation ¶
func (c *Confirm) StartConfirmation(ctx context.Context, user authboss.ConfirmableUser, sendEmail bool) error
StartConfirmation begins confirmation on a user by setting them to require confirmation via a created token, and optionally sending them an e-mail.
func (*Confirm) StartConfirmationWeb ¶
func (c *Confirm) StartConfirmationWeb(w http.ResponseWriter, r *http.Request, handled bool) (bool, error)
StartConfirmationWeb hijacks a request and forces a user to be confirmed first it's assumed that the current user is loaded into the request context.