auth

package
v0.0.0-...-ead0699 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSession

func AddSession(token, username string, expireTime time.Time)

func ChangePassword

func ChangePassword(username, currentPassword, newPassword string) bool

func ChangeUsername

func ChangeUsername(username, newUsername string) bool

func FindUser

func FindUser(username, password string) (bool, error)

func GetUsers

func GetUsers() (*[]byte, error)

func InsertUser

func InsertUser(username, password string, role UserRole) error

func LoadUsers

func LoadUsers(data *[]byte) error

func RemoveSession

func RemoveSession(token string)

func SessionUpdateUsername

func SessionUpdateUsername(oldUsername, newUsername string)

func UserLoginUpdateTime

func UserLoginUpdateTime(username string)

func VerifySession

func VerifySession(token string) (string, bool)

Types

type AllUsers

type AllUsers struct {
	Data []User `json:"data"`
}

func GetAllUsers

func GetAllUsers() AllUsers

type Session

type Session struct {
	Token      string    `json:"authToken"`
	Username   string    `json:"username"`
	ExpireTime time.Time `json:"expireTime"`
}

type User

type User struct {
	Username     string    `json:"username"`
	PasswordHash string    `json:"passwordHash"` // hash passwords
	Role         UserRole  `json:"role"`
	LastLoggedIn time.Time `json:"lastLoggedIn"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
}

type UserRole

type UserRole string
const (
	Admin   UserRole = "admin"
	General UserRole = "general"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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