users

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ban

func Ban(id string) error

Ban bans a user by changing its password hash to "banned" todo: expire user's session token

func CheckIfExists

func CheckIfExists(email string) (bool, error)

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

func CreateAccount(nickname, email, password, vt, id string) error

CreateAccount creates a new account in the database

func GetNumOfBannedUsers

func GetNumOfBannedUsers() (int, error)

GetNumOfBannedUsers returns the total number of users in the database

func GetNumOfUsers

func GetNumOfUsers() (int, error)

GetNumOfUsers returns the total number of users in the database

func GetUserID

func GetUserID(sessionToken string) (string, error)

GetUserID returns a user ID based on its email

func GetUserInfosFromSessionToken

func GetUserInfosFromSessionToken(sessionToken string) (string, string, error)

GetUserInfosFromSessionToken retrieve a nickname, an email and an user ID based on a session token

func GetValidationToken

func GetValidationToken(uid string) (string, error)

GetValidationToken returns an account validation token associated to a UID in database

func HasConfirmedAccount

func HasConfirmedAccount(id string) (bool, error)

HasConfirmedAccount returns true if the user account is confirmed, false otherwise. It also returns an error in case of failure

func IsAdmin

func IsAdmin(id string) (bool, error)

IsAdmin checks if the user is marked as admin in the database

func ValidateAccount

func ValidateAccount(id string) error

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

func GetAllUsers() ([]User, error)

GetAllUsers returns all users present in database

func GetUserInfosFromEmail

func GetUserInfosFromEmail(email string) (User, error)

GetUserInfosFromEmail returns the informations linked to a given email address

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL