auth

package
v0.0.0-...-1dc285c Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NormalUser    = 0
	Administrator = 1
)

Variables

View Source
var USER_COLLECTION string = "users"
View Source
var USER_MONGO_DB string = config.DB_NAME

Functions

This section is empty.

Types

type IUserUtils

type IUserUtils interface {
	AddUser(user *User) (primitive.ObjectID, error)
	GetUserByID(id primitive.ObjectID) (User, error)
	GetUserByAccount(account string) (User, error)
	GetUserByAccountPwd(account string, password string) (User, error)
	HasUser() (bool, error)
	UserHasScopeID(u_id primitive.ObjectID, s_id primitive.ObjectID) (bool, error)
	UpdateUser(user *User) error
}

type User

type User struct {
	ID         primitive.ObjectID `bson:"_id"`
	CreateTime time.Time
	Account    string `binding:"required"`
	Password   string `binding:"required"`
	Role       uint
	Scopes     []primitive.ObjectID
}

type UserInfo

type UserInfo struct {
	Role uint
}

type UserUtils

type UserUtils struct {
	DB_Client *mongo.Client
}

func (*UserUtils) AddUser

func (utils *UserUtils) AddUser(user *User) (primitive.ObjectID, error)

func (*UserUtils) GetUserByAccount

func (utils *UserUtils) GetUserByAccount(account string) (User, error)

func (*UserUtils) GetUserByAccountPwd

func (utils *UserUtils) GetUserByAccountPwd(account string, password string) (User, error)

func (*UserUtils) GetUserByID

func (utils *UserUtils) GetUserByID(id primitive.ObjectID) (User, error)

func (*UserUtils) HasUser

func (utils *UserUtils) HasUser() (bool, error)

func (*UserUtils) UpdateUser

func (utils *UserUtils) UpdateUser(user *User) error

func (*UserUtils) UserHasScopeID

func (utils *UserUtils) UserHasScopeID(u_id primitive.ObjectID, s_id primitive.ObjectID) (bool, error)

Jump to

Keyboard shortcuts

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