models

package
v0.0.0-...-0ddd045 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package models provides model structs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Invite

type Invite struct {
	Hash       string    `json:"hash" db:"hash"`
	CreatedBy  string    `json:"created_by" db:"created_by"`
	Server     string    `json:"server" db:"server"`
	OneTimeUse bool      `json:"one_time_use" db:"one_time_use"`
	ExpiresAt  null.Time `json:"expires_at" db:"expires_at"`
}

func (*Invite) IsEmpty

func (c *Invite) IsEmpty() bool

IsEmpty returns if all data is present

func (*Invite) ToURL

func (i *Invite) ToURL(domain string) string

ToURL returns the URL representation of the invite

type Privileges

type Privileges struct {
	ID                    uint `json:"-"`
	RoleID                uint `json:"-"`
	CanCreateServer       bool `json:"canCreateServer"`
	CanDeleteServer       bool `json:"canDeleteServer"`
	CanEditServer         bool `json:"canEditServer"`
	CanSeeAllServers      bool `json:"canSeeAllServers"`
	CanCreateRoom         bool `json:"canCreateRoom"`
	CanDeleteRoom         bool `json:"canDeleteRoom"`
	CanEditRoom           bool `json:"canEditRoom"`
	CanCreateInvite       bool `json:"canCreateInvite"`
	CanDeleteInvite       bool `json:"canDeleteInvite"`
	CanKickUserFromRoom   bool `json:"canKickUserFromRoom"`
	CanKickUserFromServer bool `json:"canKickUserFromServer"`
	CanBanUserFromRoom    bool `json:"canBanUserFromRoom"`
	CanBanUserFromServer  bool `json:"canBanUserFromServer"`
	CanCreateRole         bool `json:"canCreateRole"`
	CanDeleteRole         bool `json:"canDeleteRole"`
	CanAssignRoleToUser   bool `json:"canAssignRoleToUser"`
	CanRemoveRoleFromUser bool `json:"canRemoveRoleRromUser"`
}

Privileges manages privileges which each role has

type PublicUser

type PublicUser struct {
	Username  string `json:"username"`
	Password  string `json:"password"`
	Email     string `json:"email"`
	PublicKey string `json:"publickey"`
}

func (*PublicUser) IsInvalid

func (u *PublicUser) IsInvalid() bool

IsEmpty returns if some or all values are empty

func (*PublicUser) IsLoginEmpty

func (u *PublicUser) IsLoginEmpty() bool

IsLoginEmpty returns if all required data is set to login a user (username and password)

type Role

type Role struct {
	ID          uint       `json:"-"`
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Privileges  Privileges `json:"privileges"`
}

Role specifies a role which is used for rights management

func Basic

func Basic() Role

Basic returns the basic user role

func Superadmin

func Superadmin() Role

Superadmin returns the superadmin role

type Room

type Room struct {
	Hash        string      `json:"hash" db:"hash"`
	Name        string      `json:"name" db:"name"`
	Type        null.String `json:"type" db:"type"`
	Description null.String `json:"description" db:"description"`
}

func (*Room) Invalid

func (r *Room) Invalid() bool

Invalid returns if the data is invalid

func (*Room) IsEmpty

func (r *Room) IsEmpty() bool

IsEmpty returns if all required data is present

type Server

type Server struct {
	Hash        string      `json:"hash" db:"hash"`
	Name        string      `json:"name" db:"name"`
	Description null.String `json:"description" db:"description"`
	Image       null.String `json:"image" db:"image"`
}

func (*Server) IsEmpty

func (s *Server) IsEmpty() bool

type User

type User struct {
	Username    string      `json:"username" db:"username"`
	Password    string      `json:"-" db:"password"`
	Email       null.String `json:"email" db:"email"`
	PublicKey   string      `json:"-" db:"publickey"`
	TwoFASecret null.String `json:"-" db:"twofa_secret"`
	TwoFAVerify null.String `json:"-" db:"twofa_verify"`
}

func (*User) Invalid

func (u *User) Invalid() bool

func (*User) UsesTwoFA

func (u *User) UsesTwoFA() bool

UsesTwoFA returns if the user uses 2FA

Jump to

Keyboard shortcuts

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