store

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package store provides a small local SQLite database for user names and password hashes, used for login and registration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootstrapFromEnv

func BootstrapFromEnv(adminUser, adminPassword string) error

BootstrapFromEnv creates the first user from SYNC_ADMIN_USER and SYNC_ADMIN_PASSWORD if the DB has no users.

func CreateToken

func CreateToken(userId string) (string, error)

CreateToken creates a session token for the user (by userId) and returns it. Caller must store it.

func CreateUser

func CreateUser(username, password string) (userId string, err error)

CreateUser adds a user with the given password (hashed with bcrypt). Returns userId (UUID). If user already exists, returns their id and nil.

func GetUserIdByUsername

func GetUserIdByUsername(username string) string

GetUserIdByUsername returns the user's id (UUID) or empty string if not found.

func GetUsernameByUserId

func GetUsernameByUserId(userId string) string

GetUsernameByUserId returns the username (email) for the given userId, or empty string if not found.

func HasAnyUser

func HasAnyUser() (bool, error)

HasAnyUser returns true if at least one user exists (for bootstrap).

func Open

func Open(path string) error

Open opens the auth SQLite database at path (creates file and dirs if needed). Safe to call once.

func UserIdExists

func UserIdExists(id string) bool

UserIdExists returns true if the id exists in users.

func ValidateToken

func ValidateToken(token string) string

ValidateToken returns the user id if the token is valid and not expired, else empty string.

func VerifyUser

func VerifyUser(username, password string) bool

VerifyUser returns true if the username exists and the password matches.

Types

This section is empty.

Jump to

Keyboard shortcuts

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