Documentation ¶
Overview ¶
Package user provides user (related) entities and business logic.
Index ¶
Constants ¶
View Source
const ( RoleAdmin = "ADMIN" RoleUser = "USER" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Session ¶
Session is an entity for user sessions.
func GetSession ¶
GetSession returns the Session from the context. Returns an error is there's no or an invalid session in the context.
func NewSession ¶
NewSession returns an initialized user session.
func (Session) IsValid ¶
IsValid returns true if the session is valid. The session is valid if it's not expires and contains a valid User entity for the authenticated user
func (Session) UserHasRole ¶
UserHasRole returns true if the session's user has one of the provided roles.
type User ¶
type User struct { ID string `validate:"required,uuid"` Name string `validate:"required"` Email string `validate:"required,email"` PasswordHash []byte `validate:"required,notEmptyPassword"` Roles []string `validate:"required,min=1"` DateCreated time.Time `validate:"required"` DateUpdated time.Time `validate:"required"` }
func (User) HasPassword ¶
Click to show internal directories.
Click to hide internal directories.