Documentation ¶
Overview ¶
Package auth implements a service for user authentication.
Index ¶
- Constants
- type ChangePasswordUser
- type Service
- func (s *Service) AuthenticationMiddleware(next http.Handler) http.Handler
- func (s *Service) ChangePassword(w http.ResponseWriter, r *http.Request)
- func (s *Service) DeleteUser(w http.ResponseWriter, r *http.Request)
- func (s *Service) SignIn(w http.ResponseWriter, r *http.Request)
- func (s *Service) SignUp(w http.ResponseWriter, r *http.Request)
- func (s *Service) SignUpDefaultUser() error
- type SignInUser
- type SignUpUser
Constants ¶
View Source
const (
SignInError = "Invalid username or password"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangePasswordUser ¶
type ChangePasswordUser struct { OldPassword string `json:"oldPassword" validate:"required"` NewPassword string `json:"newPassword" validate:"required,min=10,max=25"` NewPasswordConfirm string `json:"newPasswordConfirm" validate:"required,eqfield=NewPassword"` }
ChangePasswordUser is a user that changes password.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a service for user authentication.
func New ¶
func New(db *db.Service, sender *email.Sender, validator *validator.Validate, signKey []byte, logger *log.Logger) *Service
New creates a new Service.
func (*Service) AuthenticationMiddleware ¶
AuthenticationMiddleware is a middleware that checks if the user is authenticated.
func (*Service) ChangePassword ¶
func (s *Service) ChangePassword(w http.ResponseWriter, r *http.Request)
ChangePassword changes a user's password.
func (*Service) DeleteUser ¶
func (s *Service) DeleteUser(w http.ResponseWriter, r *http.Request)
func (*Service) SignIn ¶
func (s *Service) SignIn(w http.ResponseWriter, r *http.Request)
SignIn signs in a user.
func (*Service) SignUp ¶
func (s *Service) SignUp(w http.ResponseWriter, r *http.Request)
SignUp signs up a user.
func (*Service) SignUpDefaultUser ¶
type SignInUser ¶
type SignInUser struct { Username string `json:"username" validate:"required,min=4,max=20,alphanum"` Password string `json:"password" validate:"required"` }
SignInUser is a user that logs in.
type SignUpUser ¶
type SignUpUser struct { Username string `json:"username" validate:"required,min=4,max=20,alphanum"` Email string `json:"email" validate:"required,email"` }
SignUpUser is a user that signs up.
Click to show internal directories.
Click to hide internal directories.