Documentation ¶
Index ¶
- Variables
- func LogoutUser(Token string)
- func RunDatabaseInitTasks()
- type User
- func (u *User) Ban()
- func (u *User) ChangeEmail(Email string)
- func (u *User) ChangePFPUrl(URL string)
- func (u *User) DemoteFromAdmin()
- func (u *User) PromoteToAdmin()
- func (u *User) SetFirstName(FirstName string)
- func (u *User) SetLastName(LastName string)
- func (u *User) SetPassword(Password string)
- func (u *User) Unban()
- func (u *User) Verify()
- type VerificationCode
Constants ¶
This section is empty.
Variables ¶
var DefaultPFPURL = "/static/png/default_pfp.png"
DefaultPFPURL is the PFP for the default user.
Functions ¶
func RunDatabaseInitTasks ¶
func RunDatabaseInitTasks()
RunDatabaseInitTasks is used to run all database initialisation tasks.
Types ¶
type User ¶
type User struct { ID string `json:"id" bson:"_id"` Email string `json:"email" bson:"email"` Verified bool `json:"verified" bson:"verified"` Admin bool `json:"admin" bson:"admin"` Banned bool `json:"banned" bson:"banned"` PasswordHashSalt string `json:"passwordHashSalt" bson:"passwordHashSalt"` FirstName *string `json:"firstName" bson:"firstName"` LastName *string `json:"lastName" bson:"lastName"` PFPUrl string `json:"pfpUrl" bson:"pfpUrl"` }
User is the model which is used to define a user.
func GetUserByEmail ¶
GetUserByEmail is used to check if a user exists with their e-mail address and return it if so.
func GetUserByID ¶
GetUserByID is used to get the user by their user ID.
func GetUserByToken ¶
GetUserByToken is used to get the user by their token.
func LoginUser ¶
LoginUser is used to login a user. If the email/password is correct, a user pointer and a string pointer for a token will be returned. If it is not correct, these will be nil.
func NewUser ¶
func NewUser(Email, Password string, Admin, Verified bool, FirstName, LastName *string) (*User, string)
NewUser is used to create a new user and new token with it.
func (*User) ChangeEmail ¶
ChangeEmail is used to change an email within the database.
func (*User) ChangePFPUrl ¶
ChangePFPUrl is used to change the PFP URL within the database.
func (*User) DemoteFromAdmin ¶
func (u *User) DemoteFromAdmin()
DemoteFromAdmin is used to demote a user from admin.
func (*User) PromoteToAdmin ¶
func (u *User) PromoteToAdmin()
PromoteToAdmin is used to promote a user to admin.
func (*User) SetFirstName ¶
SetFirstName is used to set a first name in the database.
func (*User) SetLastName ¶
SetLastName is used to set a last name in the database.
func (*User) SetPassword ¶
SetPassword is used to set a password in the database.
type VerificationCode ¶
type VerificationCode struct { ID string `json:"id" bson:"_id"` UserID string `json:"userId" bson:"userId"` }
VerificationCode defines a verification code model.
func GetVerificationCode ¶
func GetVerificationCode(ID string) *VerificationCode
GetVerificationCode is used to get a verification code if possible.
func NewVerificationCode ¶
func NewVerificationCode(u *User) (*VerificationCode, error)
NewVerificationCode is used to create a verification code for a user.
func (*VerificationCode) Verify ¶
func (v *VerificationCode) Verify()
Verify is used to verify the user and then delete the object from the DB.