Documentation
¶
Index ¶
- type Cookie
- func (s *Cookie) AddFlashMessage(w http.ResponseWriter, r *http.Request, flashMessage FlashMessage) error
- func (s *Cookie) DeleteSessionUser(w http.ResponseWriter)
- func (s *Cookie) FlashError(w http.ResponseWriter, r *http.Request, path string, err error, msg string, ...)
- func (s *Cookie) FlashMessage(w http.ResponseWriter, r *http.Request, path, msg string, args ...interface{})
- func (s *Cookie) GetFlashMessages(w http.ResponseWriter, r *http.Request) ([]FlashMessage, error)
- func (s *Cookie) GetSessionUser(r *http.Request) (repo.SessionUser, error)
- func (s *Cookie) StoreSessionUser(w http.ResponseWriter, sessionUser repo.SessionUser)
- type File
- func (f *File) Get(ctx context.Context, name string) (repo.FileModel, error)
- func (f *File) List(ctx context.Context, access []string, isAdmin bool) (repo.FileModels, error)
- func (f *File) Retrieve(ctx context.Context, name string, access []string) ([]byte, error)
- func (f *File) Upload(ctx context.Context, name string, content []byte, access []string) (repo.FileModel, error)
- type FileRepo
- type FileSystem
- type FlashMessage
- type Level
- type PasswordChecker
- type PasswordHasher
- type SessionRepo
- type User
- func (u *User) CheckPassword(ctx context.Context, userName, password string) error
- func (u *User) CheckPasswordHash(ctx context.Context, password, hash string) error
- func (u *User) Create(ctx context.Context, name, email, password string, isAdmin bool, ...) (repo.UserModel, error)
- func (u *User) Delete(ctx context.Context, name string) error
- func (u *User) Demote(ctx context.Context, name string) (repo.UserModel, error)
- func (u *User) HashPassword(ctx context.Context, password string) (string, error)
- func (u *User) List(ctx context.Context) (repo.UserModels, error)
- func (u *User) Login(ctx context.Context, userName, password string) (repo.SessionUser, error)
- func (u *User) Promote(ctx context.Context, name string) (repo.UserModel, error)
- func (u *User) UpdateAccess(ctx context.Context, name string, access []string) (repo.UserModel, error)
- func (u *User) UpdatePassword(ctx context.Context, name, password string) (repo.UserModel, error)
- type UserRepo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cookie ¶
type Cookie struct {
// contains filtered or unexported fields
}
Cookie represents a cookie service.
func NewCookie ¶
func NewCookie(cookieStore *securecookie.SecureCookie, logger log.Logger) *Cookie
NewCookie creates a new Cookie service.
func (*Cookie) AddFlashMessage ¶
func (s *Cookie) AddFlashMessage(w http.ResponseWriter, r *http.Request, flashMessage FlashMessage) error
AddFlashMessage stores a new FlashMessage in a cookie.
func (*Cookie) DeleteSessionUser ¶
func (s *Cookie) DeleteSessionUser(w http.ResponseWriter)
DeleteSessionUser deletes a SessionUser from a cookie.
func (*Cookie) FlashError ¶
func (s *Cookie) FlashError(w http.ResponseWriter, r *http.Request, path string, err error, msg string, args ...interface{})
FlashError sets up a temporary session message for an error.
func (*Cookie) FlashMessage ¶
func (s *Cookie) FlashMessage(w http.ResponseWriter, r *http.Request, path, msg string, args ...interface{})
FlashMessage sets up a temporary session message.
func (*Cookie) GetFlashMessages ¶
func (s *Cookie) GetFlashMessages(w http.ResponseWriter, r *http.Request) ([]FlashMessage, error)
GetFlashMessages retrieves a slice of FlashMessage objects from a cookie and deletes it.
func (*Cookie) GetSessionUser ¶
GetSessionUser retrieves a SessionUser from a cookie.
func (*Cookie) StoreSessionUser ¶
func (s *Cookie) StoreSessionUser(w http.ResponseWriter, sessionUser repo.SessionUser)
StoreSessionUser stores a SessionUser in a cookie.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a service that provides file-related operations.
func NewFile ¶
func NewFile(fileRepo FileRepo, store FileSystem, logger log.Logger) *File
NewFile creates a new File service.
type FileSystem ¶
type FlashMessage ¶
FlashMessage represents a message to be displayed to the user.
type PasswordChecker ¶
type PasswordHasher ¶
type SessionRepo ¶
type User ¶
type User struct {
// contains filtered or unexported fields
}
User is a service that provides user-related operations.
func NewUser ¶
func NewUser(userRepo UserRepo, passwordHasher PasswordHasher, passwordChecker PasswordChecker, logger log.Logger) *User
NewUser creates a new User service.
func (*User) CheckPassword ¶
CheckPassword checks if the given username and password are correct.
func (*User) CheckPasswordHash ¶
CheckPasswordHash checks if the given hash is a valid hash for a given password.
func (*User) Create ¶
func (u *User) Create(ctx context.Context, name, email, password string, isAdmin bool, access []string) (repo.UserModel, error)
Create creates a new user. It hashes the password and stores the user in the repository. It also checks if the raw password is OK.
func (*User) HashPassword ¶
HashPassword hashes a given password.
func (*User) Login ¶
Login logs in a user with the given username and password and returns a session hash.
type UserRepo ¶
type UserRepo interface {
Get(ctx context.Context, name string) (repo.UserModel, error)
List(ctx context.Context) (repo.UserModels, error)
Create(ctx context.Context, name, email, password string, isAdmin bool, access []string) (repo.UserModel, error)
UpdatePassword(ctx context.Context, name, password string) (repo.UserModel, error)
UpdateAccess(ctx context.Context, name string, access []string) (repo.UserModel, error)
Promote(ctx context.Context, name string) (repo.UserModel, error)
Demote(ctx context.Context, name string) (repo.UserModel, error)
Delete(ctx context.Context, name string) error
}