Documentation ¶
Index ¶
- func Ban(id string) error
- func CheckIfExists(email string) (bool, error)
- func CreateAccount(nickname, email, password, vt, id string) error
- func GetNumOfBannedUsers() (int, error)
- func GetNumOfUsers() (int, error)
- func GetUserID(sessionToken string) (string, error)
- func GetUserInfosFromSessionToken(sessionToken string) (string, string, error)
- func GetValidationToken(uid string) (string, error)
- func HasConfirmedAccount(id string) (bool, error)
- func IsAdmin(id string) (bool, error)
- func ValidateAccount(id string) error
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ban ¶
Ban bans a user by changing its password hash to "banned" todo: expire user's session token
func CheckIfExists ¶
CheckIfExists checks if a user already exists in the database. It detects if the emails contains a +. If it is the case and if the fixed part is already present, it returns false
func CreateAccount ¶
CreateAccount creates a new account in the database
func GetNumOfBannedUsers ¶
GetNumOfBannedUsers returns the total number of users in the database
func GetNumOfUsers ¶
GetNumOfUsers returns the total number of users in the database
func GetUserInfosFromSessionToken ¶
GetUserInfosFromSessionToken retrieve a nickname, an email and an user ID based on a session token
func GetValidationToken ¶
GetValidationToken returns an account validation token associated to a UID in database
func HasConfirmedAccount ¶
HasConfirmedAccount returns true if the user account is confirmed, false otherwise. It also returns an error in case of failure
func ValidateAccount ¶
ValidateAccount validates a user account based in its userId
Types ¶
type User ¶
type User struct { ID string `db:"id"` Nickname string `db:"nick_name"` Email string `db:"email"` IsAdmin bool `db:"is_admin"` HasConfirmedAccount bool `db:"has_confirmed_account"` HashedPassword string `db:"password_hash"` CreatedAt time.Time `db:"created_at"` AccountValidationToken string `db:"account_validation_token"` }
func GetAllUsers ¶
GetAllUsers returns all users present in database
func GetUserInfosFromEmail ¶
GetUserInfosFromEmail returns the informations linked to a given email address