Documentation ¶
Index ¶
- func CheckPasswordHash(u *User, plainPassword string) bool
- func CheckUser() gin.HandlerFunc
- func Count() int
- func CountAdmins() int
- func Delete(key string) error
- func DeleteSession(sess *UserSession) error
- func DeleteToken(token string) error
- func ExtractUser() gin.HandlerFunc
- func FlushCaches()
- func GetToken(token string) (string, error)
- func HashPassword(u *User) error
- func Init(store *bolthold.Store, eventBus *hub.Hub)
- func Insert(user *User, upsert bool) error
- func InsertSession(sess *UserSession, upsert bool) error
- func InsertToken(token, userID string) error
- func NewSessionValidator(cfg *config.Config, resolveUser userResolver) userSessionValidator
- func NewUserCredentialsValidator(cfg *config.Config, checkPw bool) userCredentialsValidator
- func NewUserValidator(cfg *config.Config, checkPw bool) userValidator
- func RegisterAPIRoutes(router *gin.Engine, group *gin.RouterGroup)
- func RegisterRoutes(router *gin.Engine, group *gin.RouterGroup)
- func Reindex()
- func SendConfirmationMail(u *User, activationCode string) error
- func ValidateRecaptcha(token, ip string) bool
- type Login
- type User
- type UserQuery
- type UserSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
CheckPasswordHash checks a given password string against the user's hashed password
func CheckUser ¶
func CheckUser() gin.HandlerFunc
CheckUser checks whether a user is present in the current context
func CountAdmins ¶
func CountAdmins() int
CountAdmins returns the total number of users with the admin flag set to true
func DeleteSession ¶
func DeleteSession(sess *UserSession) error
DeleteSession removes an existing session and causes the user to be logged out
func DeleteToken ¶
DeleteToken removes the association of the given token with its user
func ExtractUser ¶
func ExtractUser() gin.HandlerFunc
ExtractUser extracts the user information associated with the current request and attaches the user object and its related session to the context
func HashPassword ¶
HashPassword hashes the given user's plain text password in-place
func InsertSession ¶
func InsertSession(sess *UserSession, upsert bool) error
InsertSession starts a new session
func InsertToken ¶
InsertToken associates the given user Id with the given token
func NewSessionValidator ¶
NewSessionValidator instantiates a new user credentials validator
func NewUserCredentialsValidator ¶
NewUserCredentialsValidator instantiates a new user credentials validator
func NewUserValidator ¶
NewUserValidator instantiates a new user validator
func RegisterAPIRoutes ¶
func RegisterAPIRoutes(router *gin.Engine, group *gin.RouterGroup)
RegisterAPIRoutes registers all API routes with the given router instance
func RegisterRoutes ¶
func RegisterRoutes(router *gin.Engine, group *gin.RouterGroup)
RegisterRoutes registers all public routes with the given router instance
func SendConfirmationMail ¶
SendConfirmationMail sends a user registration confirmation mail with the given activation code for the given user
func ValidateRecaptcha ¶
ValidateRecaptcha is used to validate a given reCaptcha token
Types ¶
type Login ¶
type Login struct { UserId string `form:"user" binding:"required"` Password string `form:"password" binding:"required"` }
Login represents the user's credentials sent during login
type User ¶
type User struct { Id string `form:"user" binding:"required" boltholdIndex:"Id"` Password string `form:"password" binding:"required"` Active bool `form:"" boltholdIndex:"Active"` Admin bool `form:""` Gender string `form:"gender" binding:"required"` Major string `form:"major" binding:"required"` Degree string `form:"degree" binding:"required"` CreatedAt time.Time `form:""` }
User represents a registered user in this application
func (*User) HasValidCredentials ¶
HasValidCredentials checks whether the user has valid credentials according to a given validation function
type UserSession ¶
UserSession represents a user's login session
func GetAllSessions ¶
func GetAllSessions() ([]*UserSession, error)
GetAllSessions returns all registered user sessions for debugging purposes
func GetSession ¶
func GetSession(token string) (*UserSession, error)
GetSession retrieves an existing session by its used token
func (*UserSession) IsValid ¶
func (s *UserSession) IsValid(validator userSessionValidator) bool
IsValid checks whether the session is valid according to a given validation function