confirm

package
v2.0.0-rc2+incompatible Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: MIT Imports: 10 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 GenerateToken

func GenerateToken() (hash string, token string, err error)

GenerateToken creates a random token that will be used to confirm the user.

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