Documentation ¶
Index ¶
- Constants
- Variables
- func GenPassword() string
- func GetImageMimeType(ext string) string
- func GetUserSalt() (string, error)
- func HashPassword(passwd string, salt string) string
- func IsComplexEnough(pwd string) bool
- func IsFileExtImage(ext string) bool
- func IsValidUsername(s string) bool
- type Course
- type Error
- type FileInfo
- type LoginPayload
- type Permissions
- type Role
- type User
- func (u *User) FullName() string
- func (u *User) GetID() string
- func (u *User) PasswordValid(passwd string) bool
- func (u *User) Patch(patch *UserPatch)
- func (u *User) PreSave()
- func (u *User) PreUpdate()
- func (u *User) SetID(id string)
- func (u *User) SetPassword(passwd string)
- func (u *User) SetPasswordSalt()
- func (u *User) Validate() error
- type UserGetOptions
- type UserPatch
Constants ¶
View Source
const ( LABEL_MIN_LENGTH = 1 LABEL_MAX_LENGTH = 32 TYPE_MIN_LENGTH = 1 TYPE_MAX_LENGTH = 32 SUBJECT_MIN_LENGTH = 1 SUBJECT_MAX_LENGTH = 32 )
View Source
const (
MaxImageSize = int64(6048 * 4032) // 24 megapixels, roughly 36MB as a raw image
)
Variables ¶
View Source
var ( IMAGE_EXTENSIONS = [7]string{".jpg", ".jpeg", ".gif", ".bmp", ".png", ".tiff", "tif"} IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff", ".tif": "image/tif"} )
View Source
var ( ErrUsernameIllegal = errors.New("User name contains illegal characters") ErrUsernameEmpty = errors.New("Username cannot be empty") ErrUsernameReserved = errors.New("Username is reserved") ErrUsernamePatternNotAllowed = errors.New("Pattern of username not allowed") ErrUserExists = errors.New("A user with this username already exists") ErrFirstNameTooShort = errors.New("models.user.first_name.too_short") ErrFirstNameTooLong = errors.New("models.user.first_name.too_long") ErrLastNameTooShort = errors.New("models.user.last_name.too_short") ErrLastNameTooLong = errors.New("models.user.last_name.too_long") ErrPasswordTooWeak = errors.New("Password does not meet requirements") )
Functions ¶
func GenPassword ¶
func GenPassword() string
func GetImageMimeType ¶
func GetUserSalt ¶
GetUserSalt generates a random string to use for salting passwords
func HashPassword ¶
func IsComplexEnough ¶
IsComplexEnough checks if a given password meets the required complexity
func IsFileExtImage ¶
func IsValidUsername ¶
Types ¶
type Course ¶
type Course struct { ID string `json:"id,omitempty" bson:"_id,omitempty"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` Label string `bson:"label"` Type string `bson:"type"` Subject string `bson:"subject"` StudentIDs []string `bson:"studentIds"` InstructorIDs []string `bson:"instructorIds"` }
type Error ¶
Error represents an internal error that may occur during a request
type FileInfo ¶
type LoginPayload ¶
type Permissions ¶
type Role ¶
type Role struct { // The roles ID ID string `bson:"_id,omitempty"` // The name of the role Name string `bson:"name,omitempty"` // A short description of the role Description string `bson:"description,omitempty"` // The permissions the role has Permissions Permissions `bson:"permissions,omitempty"` }
Role represents a users role that can have multiple permissions to access parts of the api and therefore can modify the websites content.
type User ¶
type User struct { ID string `json:"id,omitempty" bson:"_id,omitempty"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` Username string `json:"username,omitempty"` Email string `json:"email,omitempty"` EmailVerified bool `json:"emailVerified"` Password string `json:"password,omitempty"` PasswordUpdatedAt time.Time `json:"passwordUpdatedAt"` Salt string `json:"salt,omitempty"` Type string `json:"type,omitempty"` FirstName string `json:"firstName,omitempty"` LastName string `json:"lastName,omitempty"` LastLogin time.Time `json:"lastLogin,omitempty"` }
User represents a user that can be of type instructor, student, parent or staff. A user can access parts of the website or the admin section based on roles and permissions.
func (*User) PasswordValid ¶
PasswordValid validates a given password.
func (*User) SetPassword ¶
SetPassword hashes the users password with a generated salt.
func (*User) SetPasswordSalt ¶
func (u *User) SetPasswordSalt()
type UserGetOptions ¶
Click to show internal directories.
Click to hide internal directories.