db

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteUser

func DeleteUser(uid string) error

DeleteUser deletes the given user from the db

func DisableUser

func DisableUser(uid string) error

DisableUser disables the given user

func EnableUser

func EnableUser(uid string) error

EnableUser enables the given user

func IsUserEnabled

func IsUserEnabled(uid string) bool

IsUserEnabled returns whether the given user is enabled

func Setup

func Setup() error

Setup sets up the connection to the local sqlite db. Creates the user table if it not exists

Types

type User

type User struct {
	Username string
	Enabled  bool
}

User is the model mapping to the table in the db

func ListUsers

func ListUsers() ([]User, error)

ListUsers lists all users in the db

type UserData

type UserData struct {
	Token string // Token is the jwt token for the user
	Uid   string // Uid is the id of the user in the db
}

UserData represents the data generated on login

func LoginUser

func LoginUser(username string, password string) (UserData, error)

LoginUser logs the user in using the local db

func RegisterUser

func RegisterUser(username string, password string) (UserData, error)

RegisterUser creates a new user and saves the user to db. The password is hashed using sha256

Jump to

Keyboard shortcuts

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