Documentation
¶
Index ¶
- Constants
- Variables
- type AuthenticationMiddleware
- type ChangePasswordHandler
- type Domain
- type GetHandler
- type LoginHandler
- type LogoutHandler
- type RegisterHandler
- type Repository
- func (r *Repository) Create(ctx context.Context, user *User) error
- func (r *Repository) Get(ctx context.Context, id string) (*User, error)
- func (r *Repository) GetByUsername(ctx context.Context, username string) (*User, error)
- func (r *Repository) Migrations() []database.Migration
- func (r *Repository) UpdatePassword(ctx context.Context, id, password, salt string) error
- type Service
- func (s *Service) ChangePassword(ctx context.Context, currentPassword, newPassword string) error
- func (s *Service) CookieName() string
- func (s *Service) CreateSessionFromUsernameAndPassword(ctx context.Context, username, password string) (string, error)
- func (s *Service) CreateWithLoginAndPassword(ctx context.Context, username, password string) error
- func (s *Service) DeleteSession(ctx context.Context, sessionId string) error
- func (s *Service) Get(ctx context.Context, id string) (*User, error)
- func (s *Service) GetFromSession(ctx context.Context, sessionId string) (*User, error)
- type Status
- type User
Constants ¶
View Source
const (
UserContextKey contextKey = "user"
)
Variables ¶
View Source
var ( ErrUserNotFound = errors.New("user not found") ErrWrongUserOrPassword = errors.New("wrong user or password") ErrInvalidUsername = errors.New("invalid username") ErrShortUsername = errors.New("short username") ErrLongUsername = errors.New("long username") ErrInvalidPassword = errors.New("invalid password") ErrShortPassword = errors.New("short password") ErrLongPassword = errors.New("long password") ErrCurrentPasswordIncorrect = errors.New("current password is incorrect") )
Functions ¶
This section is empty.
Types ¶
type AuthenticationMiddleware ¶
type AuthenticationMiddleware struct {
// contains filtered or unexported fields
}
func NewAuthenticationMiddleware ¶
func NewAuthenticationMiddleware(userService userService) *AuthenticationMiddleware
type ChangePasswordHandler ¶
type ChangePasswordHandler struct {
// contains filtered or unexported fields
}
func NewChangePasswordHandler ¶
func NewChangePasswordHandler(service *Service) *ChangePasswordHandler
func (*ChangePasswordHandler) ServeHTTP ¶
func (h *ChangePasswordHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Domain ¶
type Domain struct {
Repository *Repository
Service *Service
HandleGroup *httpserver.HandlerGroup
Middleware httpserver.Middleware
}
func (*Domain) GetRepository ¶
type GetHandler ¶
type GetHandler struct {
// contains filtered or unexported fields
}
func NewGetHandler ¶
func NewGetHandler(service *Service) *GetHandler
func (*GetHandler) ServeHTTP ¶
func (h *GetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LoginHandler ¶
type LoginHandler struct {
// contains filtered or unexported fields
}
func NewLoginHandler ¶
func NewLoginHandler(service *Service) *LoginHandler
func (*LoginHandler) ServeHTTP ¶
func (h *LoginHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LogoutHandler ¶
type LogoutHandler struct {
// contains filtered or unexported fields
}
func NewLogoutHandler ¶
func NewLogoutHandler(service *Service) *LogoutHandler
func (*LogoutHandler) ServeHTTP ¶
func (h *LogoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RegisterHandler ¶
type RegisterHandler struct {
// contains filtered or unexported fields
}
func NewRegisterHandler ¶
func NewRegisterHandler(service *Service) *RegisterHandler
func (*RegisterHandler) ServeHTTP ¶
func (h *RegisterHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db db) *Repository
func (*Repository) GetByUsername ¶
func (*Repository) Migrations ¶
func (r *Repository) Migrations() []database.Migration
func (*Repository) UpdatePassword ¶
func (r *Repository) UpdatePassword(ctx context.Context, id, password, salt string) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) ChangePassword ¶
func (*Service) CookieName ¶
func (*Service) CreateSessionFromUsernameAndPassword ¶
func (*Service) CreateWithLoginAndPassword ¶
func (*Service) DeleteSession ¶
type User ¶
type User struct {
ID string `db:"id" json:"id"`
Username string `db:"username" json:"username"`
Password string `db:"password" json:"password"`
Salt string `db:"salt" json:"salt"`
Created time.Time `db:"created" json:"created"`
Updated time.Time `db:"updated" json:"updated"`
Status Status `db:"status" json:"status"`
}
func UserFromContext ¶
Click to show internal directories.
Click to hide internal directories.