autherrors

package
v1.6.9 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Auth errors
	ErrPwdCasingUpper  errs.Error = "password must contain at least one uppercase letter, and at least one lowercase letter"
	ErrPwdCasingLower  errs.Error = "password must contain at least one lowercase letter, and at least one uppercase letter"
	ErrPwdDigits       errs.Error = "password must contain at least one digit, and at least one non-digit"
	ErrPwdSpaces       errs.Error = "password must not contain spaces"
	ErrPwdSpecial      errs.Error = "password must contain at least one special character"
	ErrInvalidLogin    errs.Error = "invalid value, please try again"
	ErrInvalidEmail    errs.Error = "invalid email address"
	ErrInvalidUsername errs.Error = "invalid username"
	ErrUserExists      errs.Error = "user already exists"
	ErrIsActive        errs.Error = "user account is not active"
	ErrPasswordInvalid errs.Error = "invalid password"
	ErrPwdHashMismatch errs.Error = "password is not valid"
	ErrPwdNoMatch      errs.Error = "passwords do not match"
	ErrGenericAuthFail errs.Error = "authentication failed"
	ErrNoSession       errs.Error = "no session found"
)
View Source
const AUTH_ERROR_HOOK = "auth.errors.AuthenticationError"

Variables

This section is empty.

Functions

func Fail

func Fail(code int, msg string, next ...string)

Authentication errors can be raised using autherrors.Fail(...)

This makes sure boilerplate code for failing auth is not repeated.

It also allows for a more consistent way to handle auth errors.

We have a hook setup to catch any authentication errors and redirect to the login page (see hooks.go)

func OnAuthenticationError added in v1.6.9

func OnAuthenticationError(h AuthErrorHook)

func RegisterHook

func RegisterHook()

Types

type AuthErrorHook added in v1.6.9

type AuthErrorHook func(w http.ResponseWriter, r *http.Request, app *django.Application, err *AuthenticationError) (written bool)

type AuthenticationError added in v1.6.9

type AuthenticationError struct {
	Message string
	NextURL string
	Status  int
}

func (*AuthenticationError) Error added in v1.6.9

func (e *AuthenticationError) Error() string

func (*AuthenticationError) StatusCode added in v1.6.9

func (e *AuthenticationError) StatusCode() int

func (*AuthenticationError) UserMessage added in v1.6.9

func (e *AuthenticationError) UserMessage() string

Jump to

Keyboard shortcuts

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