Documentation ¶
Overview ¶
Package user groups together user authentication code. Authenticating the user, signing in, retrieving signed-in current user, etc.
Index ¶
- func NewFirstTimeRegistrationGetHandler(te adapter.TemplateExecutor, ar adapter.AssetsResolver) http.Handler
- func NewFirstTimeRegistrationPostHandler(us Store, de *schema.Decoder) http.Handler
- func NewSignInGetHandler(te adapter.TemplateExecutor, ar adapter.AssetsResolver) http.Handler
- func NewSignInPostHandler(userStore Store, sessionManager *sessionup.Manager, decoder *schema.Decoder) http.Handler
- func NewSignOutPostHandler(sessionManager *sessionup.Manager) http.Handler
- func Register(router *mux.Router, templateExecutor adapter.TemplateExecutor, ...)
- type Current
- type DAO
- type PossibleMatch
- type Registration
- type RegistrationForm
- type SignInForm
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFirstTimeRegistrationGetHandler ¶
func NewFirstTimeRegistrationGetHandler( te adapter.TemplateExecutor, ar adapter.AssetsResolver, ) http.Handler
NewFirstTimeRegistrationGetHandler creates a new handler for GET /first-time-registration
func NewFirstTimeRegistrationPostHandler ¶
NewFirstTimeRegistrationPostHandler creates a new handler for POST /first-time-registration
func NewSignInGetHandler ¶
func NewSignInGetHandler( te adapter.TemplateExecutor, ar adapter.AssetsResolver, ) http.Handler
NewSignInGetHandler creates a new handler for GET /sign-in
func NewSignInPostHandler ¶
func NewSignInPostHandler( userStore Store, sessionManager *sessionup.Manager, decoder *schema.Decoder, ) http.Handler
NewSignInPostHandler creates a new handler for POST /sign-in
func NewSignOutPostHandler ¶
NewSignOutPostHandler creates a new handler for POST /sign-out
Types ¶
type DAO ¶
type DAO struct {
// contains filtered or unexported fields
}
DAO implements Store
func (*DAO) GetUserMatchingEmail ¶
GetUserMatchingEmail retrieves the user matching the provided email address. If the email is found, it will return a PossibleMatch. If it isn't found, it will return an error.
func (*DAO) GetUserMatchingSession ¶
GetUserMatchingSession retrieves the current user from the current session attached to the request context.
func (*DAO) SaveFirstAdministrator ¶
func (d *DAO) SaveFirstAdministrator(ctx context.Context, registration *Registration) error
SaveFirstAdministrator creates the first administrator account whose credentials are given in the registration.
type PossibleMatch ¶
PossibleMatch represents a user with the same email credential as the one provided in the sign-in form. It still needs to check the password matches.
type Registration ¶
Registration represents the data needed to save the user in databse. Instead of a password, it needs a password hash.
type RegistrationForm ¶
type RegistrationForm struct { Email string `schema:"email,required"` Password string `schema:"password,required"` Username string `schema:"username,required"` }
RegistrationForm represents the registration information provided by users to create their account
type SignInForm ¶
type SignInForm struct { Email string `schema:"email,required"` Password string `schema:"password,required"` }
SignInForm represents the credentials provided by users to sign in
type Store ¶
type Store interface { GetUserMatchingEmail(ctx context.Context, email string) (*PossibleMatch, error) GetUserMatchingSession(ctx context.Context) (*Current, error) SaveFirstAdministrator(ctx context.Context, registration *Registration) error }
Store handles database operations related to Users