user

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package user implements model of bucket.

Index

Constants

This section is empty.

Variables

View Source
var Admin = &Role{"admin", ^uint(0)}
View Source
var Guest = &Role{"guest", 0}
View Source
var Redirects = map[*Role]string{
	Guest: "/",
	Admin: "/admin",
}
View Source
var Roles = []*Role{
	Guest, Admin,
}

Functions

func CheckUser

func CheckUser(db_ db.DB, userStr string) bool

func SetRedirectsForRoles

func SetRedirectsForRoles(redirects map[*Role]string)

func SetRoles

func SetRoles(roles []*Role)

Types

type Role

type Role struct {
	Name   string `json:"name"`
	Access uint   `json:"access"`
}

Role implements access to module site

func GetRole

func GetRole(name string, access ...uint) *Role

type User

type User struct {
	ID       any    `json:"id"`
	Login    string `json:"login"`
	Password string `json:"password"`
	Role     *Role  `json:"role"`

	ExtraFields map[string]any `json:"extraFields"`
}

User presents model of bucket.

func Create

func Create(db_ db.DB, userStr string) *User

func CreateIfExists

func CreateIfExists(db_ db.DB, userStr string) *User

func (User) Create

func (user User) Create(db_ db.DB, userStr string) db.Model

func (User) Delete

func (user User) Delete(db_ db.DB) error

func (User) Id

func (user User) Id() any

func (*User) Save

func (user *User) Save(bucket db.Table) error

Save implements saving model in bucket.

Jump to

Keyboard shortcuts

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