user

package
v1.0.0-beta9 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitRoute

func InitRoute(r fiber.Router)

Types

type Scope

type Scope struct {
	Name string
}

type ScopeStruct

type ScopeStruct []Scope

func (*ScopeStruct) Scan

func (sla *ScopeStruct) Scan(value interface{}) error

func (ScopeStruct) Value

func (sla ScopeStruct) Value() (driver.Value, error)

type Token

type Token struct {
	Id     string `gorm:"primaryKey" json:"id"`
	Name   string `json:"name"`
	UserId string `gorm:"index" json:"-"`

	Scope ScopeStruct `gorm:"type:longtext" json:"scope"`

	CreatedAt int64 `json:"created_at"`
}

type User

type User struct {
	Id       string `gorm:"primaryKey" json:"id"`
	Username string `gorm:"index" json:"username"`
	Password string `json:"password,omitempty"`
	Email    string `json:"email"`
	Avatar   string `json:"avatar" gorm:"default:''"`
	DarkMode string `json:"dark_mode" gorm:"default:'auto'"`

	Tokens []Token `json:"tokens" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

type UserRepository

type UserRepository interface {
	FindUserByUsername(username string) (User, *exception.AppError)
	UpdateUser(user User) *exception.AppError
	CreateToken(token Token) *exception.AppError
	FindTokenById(id string) (Token, *exception.AppError)
	DeleteTokenById(id, userId string) *exception.AppError
}

type UserRepositoryDB

type UserRepositoryDB struct {
	// contains filtered or unexported fields
}

func NewUserRepository

func NewUserRepository() UserRepositoryDB

func (UserRepositoryDB) CreateToken

func (d UserRepositoryDB) CreateToken(token Token) *exception.AppError

func (UserRepositoryDB) DeleteTokenById

func (d UserRepositoryDB) DeleteTokenById(id, userId string) *exception.AppError

func (UserRepositoryDB) FindTokenById

func (d UserRepositoryDB) FindTokenById(id string) (Token, *exception.AppError)

func (UserRepositoryDB) FindUserByUsername

func (d UserRepositoryDB) FindUserByUsername(username string) (User, *exception.AppError)

func (UserRepositoryDB) UpdateUser

func (d UserRepositoryDB) UpdateUser(user User) *exception.AppError

Jump to

Keyboard shortcuts

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