Documentation
¶
Index ¶
Constants ¶
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" )
const AUTH_ERROR_HOOK = "auth.errors.AuthenticationError"
Variables ¶
This section is empty.
Functions ¶
func Fail ¶
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(reversePath string)
register a hook that will redirect the user to the login page if an authentication error occurs.
Authentication errors can be raised using auth.Fail(...)
Under the hood this induced a panic; which is then caught by django and allows for more advanced error handling.
This makes sure boilerplate code for failing auth is not repeated.
It also allows for a more consistent way to handle auth errors.
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
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