user

package
v0.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

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

func (u *User) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate ensures UUID is set.

func (*User) BeforeSave

func (u *User) BeforeSave(_ *gorm.DB) (err error)

BeforeSave ensures that user is part of either Black, Blue, or Red roles. It also ensures that username is alphanumeric

func (*User) IsCorrectPassword

func (u *User) IsCorrectPassword(password string) bool

IsCorrectPassword compares password to the hash

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL