passreset

package
v1.0.8 Latest Latest
Warning

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

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

Documentation

Overview

Package passreset provies a handler for password reset token generation, validation, and deletion. Tokens are one-time use and can be expired without use.

Index

Constants

View Source
const (
	// CookieName is the header name for post requests
	CookieName = "X-Post-PassReset"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	*session.Handler
}

Handler handles the creation and validation of password reset tokens

func NewHandler

func NewHandler(db *sql.DB, tableName string, timeout time.Duration, secret []byte) *Handler

NewHandler creates a new handler using the database pointer.

func (*Handler) GenerateNewToken

func (c *Handler) GenerateNewToken(username string) *Token

GenerateNewToken generates a new token for protecting against CSRF

func (*Handler) ValidHeaderToken

func (c *Handler) ValidHeaderToken(r *http.Request) (string, error)

ValidHeaderToken verifies that a password reset token is valid and then destroys it. This method is used in post requests.

func (*Handler) ValidToken

func (c *Handler) ValidToken(r *http.Request) (string, error)

ValidToken verifies that a password reset token is valid and then destroys it. Returns the username of the user for a valid token and "" when there is an error.

type Token

type Token struct {
	*sessions.Session
}

A Token represents a token used to reset passswords

func (*Token) Query

func (p *Token) Query() string

Query returns the request query needed for the token

Jump to

Keyboard shortcuts

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