Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUsernameTaken is thrown if username is already taken while creating an user ErrUsernameTaken = errors.New("This username is already taken") // ErrUserNotFound is thrown if user is not found when searching users from database ErrUserNotFound = errors.New("User not found") )
Functions ¶
func DoesAdminExist ¶
DoesAdminExist checks if there is any account in the database that has admin rights
func UpdateEmail ¶
UpdateEmail replaces specific users email in database with the new email.
func UpdatePassword ¶
UpdatePassword updates the users password hash with the new passwords hash
func UpdateRealName ¶
UpdateRealName updates users real name to database
func UpdateUsername ¶
UpdateUsername replaces users username on database with new username.
Types ¶
type User ¶
type User struct { Username string Fullname string Email string PasswordHash string UUID string LastLogin int64 Online bool PermissionLevel int // PermissionLevel tells the system what actions user can do. Only users with permissionlevel of over 3 can create new users. TemporaryAdmin bool }
User represents an user of this service
PermissionLevel:
Basically permissionlevels work like this:
0: Student, has all basic permissions
1: Teacher, can assing students to own groups
2: Manager, can manage groups and schedules
3: Admin, can create new subjects, courses and users
func CreateTemporaryAdmin ¶
CreateTemporaryAdmin creates an user that has temp admin rights, it is deleted when it is first used.
func CreateUser ¶
func CreateUser(username string, permissionLevel int, fullName string, email string, password string) (User, error)
CreateUser makes a new user and saves it to database. It returns the user.
func GetUserByName ¶
GetUserByName returns an user based on username