Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Black is an administrator role. Black Team - an Administrator team responsible for Infrastructure Black = "black" // Blue is a competitor role. Blue = "blue" // Red is a role of Hackers. Red = "red" Anonymous = "" )
Following are available user roles.
Variables ¶
View Source
var ErrInvalidRoleSpecified = errors.New("incorrect role specified")
View Source
var ErrNameMustBeAlphanumeric = errors.New("name must be alphanumeric")
Functions ¶
This section is empty.
Types ¶
type User ¶
type User struct { ID uuid.UUID `json:"id,omitempty" gorm:"type:uuid;primary_key;"` Username string `json:"username" gorm:"unique;not null;default:null"` PasswordHash string `json:"password_hash" gorm:"not null;default:null"` TeamID uuid.UUID `json:"team_id,omitempty" gorm:"type:uuid"` Role string `json:"role" gorm:"default:'blue'"` }
func (*User) BeforeCreate ¶
BeforeCreate ensures UUID is set.
func (*User) BeforeSave ¶
BeforeSave ensures that user is part of either Black, Blue, or Red roles. It also ensures that username is alphanumeric
func (*User) IsCorrectPassword ¶
IsCorrectPassword compares password to the hash
Click to show internal directories.
Click to hide internal directories.