confirm

package
v2.4.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package confirm implements confirmation of user registration via e-mail

Index

Constants

View Source
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

func GenerateConfirmCreds() (selector, verifier, token string, err error)

GenerateConfirmCreds generates pieces needed for user confirm 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

func Middleware(ab *authboss.Authboss) func(http.Handler) http.Handler

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

type Confirm struct {
	*authboss.Authboss
}

Confirm module

func (*Confirm) Get

func (c *Confirm) Get(w http.ResponseWriter, r *http.Request) error

Get is a request that confirms a user with a valid token

func (*Confirm) Init

func (c *Confirm) Init(ab *authboss.Authboss) (err error)

Init module

func (*Confirm) PreventAuth

func (c *Confirm) PreventAuth(w http.ResponseWriter, r *http.Request, handled bool) (bool, error)

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

func (c *Confirm) SendConfirmEmail(ctx context.Context, to, token string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL