auth

package
v0.0.0-...-3bb7120 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmailAlreadyTaken        = errors.New("email already taken")
	ErrInvalidCredentials       = errors.New("invalid credentials")
	ErrInvalidOTP               = errors.New("invalid OTP")
	ErrEmailNotConfirmed        = errors.New("email not confirmed")
	ErrAccountBlocked           = errors.New("account blocked")
	ErrInvalidOrExpiredResetURL = errors.New("invalid or expired reset URL")
	ErrOAuth2RegisteredAccount  = errors.New("OAuth2 registered account")
)

Functions

func NewAuthService

func NewAuthService(config ServiceConfig) anor.AuthService

func RegisterRoutes

func RegisterRoutes(h *Handler, router *anor.Router)

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(cfg *HandlerConfig) *Handler

func (*Handler) ForgotPasswordView

func (h *Handler) ForgotPasswordView(w http.ResponseWriter, r *http.Request)

func (*Handler) GoogleCallback

func (h *Handler) GoogleCallback(w http.ResponseWriter, r *http.Request)

func (*Handler) GoogleSignin

func (h *Handler) GoogleSignin(w http.ResponseWriter, r *http.Request)

func (*Handler) RedirectAuth

func (h *Handler) RedirectAuth(next http.Handler) http.Handler

func (*Handler) Render

func (h *Handler) Render(w http.ResponseWriter, r *http.Request, templatePath string, td templates.TemplateData)

func (*Handler) ResendOTP

func (h *Handler) ResendOTP(w http.ResponseWriter, r *http.Request)

func (*Handler) ResetPassword

func (h *Handler) ResetPassword(w http.ResponseWriter, r *http.Request)

func (*Handler) ResetPasswordView

func (h *Handler) ResetPasswordView(w http.ResponseWriter, r *http.Request)
func (h *Handler) SendResetPasswordLink(w http.ResponseWriter, r *http.Request)

func (*Handler) Signin

func (h *Handler) Signin(w http.ResponseWriter, r *http.Request)

func (*Handler) SigninView

func (h *Handler) SigninView(w http.ResponseWriter, r *http.Request)

func (*Handler) Signup

func (h *Handler) Signup(w http.ResponseWriter, r *http.Request)

func (*Handler) SignupConfirmation

func (h *Handler) SignupConfirmation(w http.ResponseWriter, r *http.Request)

func (*Handler) SignupView

func (h *Handler) SignupView(w http.ResponseWriter, r *http.Request)

type HandlerConfig

type HandlerConfig struct {
	AuthService anor.AuthService
	CartService anor.CartService
	Session     *session.Manager
	View        *html.View
	Logger      *slog.Logger
}

type OTPGenerator

type OTPGenerator func() string

type ResendOTPForm

type ResendOTPForm struct {
	Email string
}

func (*ResendOTPForm) Bind

func (f *ResendOTPForm) Bind(r *http.Request) error

func (*ResendOTPForm) Validate

func (f *ResendOTPForm) Validate() error

type ResetPasswordForm

type ResetPasswordForm struct {
	Password        string
	ConfirmPassword string
	Token           string
}

func (*ResetPasswordForm) Bind

func (f *ResetPasswordForm) Bind(r *http.Request) error

func (*ResetPasswordForm) Validate

func (f *ResetPasswordForm) Validate() error

type SendResetPasswordLinkForm

type SendResetPasswordLinkForm struct {
	Email string
}

func (*SendResetPasswordLinkForm) Bind

func (*SendResetPasswordLinkForm) Validate

func (f *SendResetPasswordLinkForm) Validate() error

type ServiceConfig

type ServiceConfig struct {
	UserService                 anor.UserService
	Emailer                     email.Emailer
	SignupConfirmationOTPCacher auth.SignupConfirmationOTPCache
	ResetPasswordTokenCacher    auth.ResetPasswordTokenCache
	OTPGenerator                OTPGenerator
	OTPExpiration               time.Duration
	TokenGenerator              TokenGenerator
	TokenExpiration             time.Duration
	ServerURL                   string
}

type SigninForm

type SigninForm struct {
	Email    string
	Password string
}

func (*SigninForm) Bind

func (f *SigninForm) Bind(r *http.Request) error

func (*SigninForm) Validate

func (f *SigninForm) Validate() error

type SignupConfirmationForm

type SignupConfirmationForm struct {
	OTP   string
	Email string
}

func (*SignupConfirmationForm) Bind

func (*SignupConfirmationForm) Validate

func (f *SignupConfirmationForm) Validate() error

type SignupForm

type SignupForm struct {
	Name            string
	Email           string
	Password        string
	ConfirmPassword string
}

func (*SignupForm) Bind

func (f *SignupForm) Bind(r *http.Request) error

func (*SignupForm) Validate

func (f *SignupForm) Validate() error

type TokenGenerator

type TokenGenerator func() string

Jump to

Keyboard shortcuts

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