Documentation
¶
Index ¶
Constants ¶
View Source
const ( // JWT secrets JWTSecretENV = "jwt_secret" RefreshSecretENV = "refresh_secret" UserENV = "user_secret" // Cookie settings CookieDomain = "localhost" CookiePath = "/" // Token cookie names AuthToken = "token" RefreshToken = "session" UserToken = "user" UserContext = "user" )
View Source
const ( ErrInitilizing = 1 ErrClosingDatabase = 2 ErrShuttingDownServer = 3 ErrStartingServer = 4 )
OS Exit Codes
Variables ¶
View Source
var ( // System Errors ErrDatabase = errors.New("Database error") ErrNilDatabase = errors.New("Database information must not be nil") ErrBadRequest = errors.New("Bad request") // User Errors ErrInvalidTokenAndUser = errors.New("User token does not match user ID provided") ErrInvalidRefreshAndUser = errors.New("Refresh token does not match user ID provided") ErrCreatingTokens = errors.New("Error creating authentication token") ErrValidatingPassword = errors.New("Error validating password") ErrIncorrectPassword = errors.New("Incorrect password") ErrUserNotFound = errors.New("User not found") ErrInvalidPermissionsToUpdate = errors.New("Invalid permissions to update user") ErrUpdateUser = errors.New("Error updating user") ErrCreateUser = errors.New("Error creating user") ErrRetrievingAllUsers = errors.New("Unable to retrieve all users") ErrWrongArgonVersion = errors.New("Incompatible argon2 version") ErrInvalidHash = errors.New("Invalid hash") ErrReauthenticate = errors.New("Error re-authenticating") ErrLoggingOut = errors.New("Error logging user out") // User Validation Errors ErrUsernameInUse = errors.New("Username already in use") ErrEmailInUse = errors.New("Email already in use") ErrUsernameSymbols = errors.New("Username cannot contain symbols") ErrInvalidEmail = errors.New("Invalid email address") ErrPasswordTooShort = errors.New("Password must contain at least 8 characters") ErrPasswordTooLong = errors.New("Password cannot exceed 100 characters") ErrUsernameTooShort = errors.New("Username must contain at least 3 characters") ErrUsernameTooLong = errors.New("Username cannot exceed 20 characters") ErrPasswordSymbol = errors.New("Password must contain at least one symbol") ErrPasswordNum = errors.New("Password must contain at least one number") ErrPasswordCapital = errors.New("Password must contain at least one capital character") )
Application Errors
Functions ¶
This section is empty.
Types ¶
type Caption ¶
type Caption struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Image uint `gorm:"type:int;not null;unique_index:idx_captions_image" json:"image"` Message string `gorm:"type:varchar(255);not null" json:"message"` PostedBy uint `gorm:"type:int;not null" json:"posted_by"` Votes []Vote `gorm:"foreignkey:Caption" json:"votes"` }
type Image ¶
type Image struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created_at"` Slug string `gorm:"type:varchar(255);not null;unique;unique_index:idx_images_slug" json:"slug"` Source string `gorm:"type:varchar(255);not null" json:"source"` PostedBy uint `gorm:"type:int;not null;unique_index:idx_images_postedby" json:"posted_by"` Votes []Vote `gorm:"foreignkey:Image" json:"votes"` Captions []Caption `gorm:"foreignkey:Image" json:"captions"` }
type User ¶
type User struct { gorm.Model Username string `gorm:"type:varchar(20);not null;unique;unique_index:idx_users_username" json:"username"` Email string `gorm:"type:varchar(255);not null;unique;unique_index:idx_users_email" json:"email"` EmailConfirmed bool `gorm:"type:boolean" json:"emailconfirmed"` Password string `gorm:"type:varchar(255);not null" json:"password,omitempty"` Votes []Vote `gorm:"foreignkey:PostedBy" json:"votes"` Captions []Caption `gorm:"foreignkey:PostedBy" json:"captions"` Images []Image `gorm:"foreignkey:PostedBy" json:"images"` }
Click to show internal directories.
Click to hide internal directories.