users

package
v0.0.56 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

README

api/sinks/postgres/users

Database queries for the scoring user credential table. This table is the source of truth for credentials during a competition — it is seeded from the config on startup but persists changes made via password change requests across restarts.

Seeding uses insert-or-ignore so that credentials already updated in a previous run are not overwritten. Other queries cover fetching all users across every team and userlist (returned as a nested structure for easy serialization), selecting a random user for a given team and userlist (used when attaching credentials to a check before serving it to an agent), and updating a single user's password by matching on team, userlist, and username.

Documentation

Overview

Package users contains the DB functions and all SQL queries involving scoring users. This package exports an init function (InitUsers) that is required for proper use. It requires the DB conneciton to have already been initialized.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitUsers

func InitUsers(
	ctx context.Context,
	db *pgxpool.Pool,
	cfg *config.APIConfigSpec,
) error

InitUsers fills the users table in the database with default usernames and passwords. Users that have had passwords changed in a previous run of the API will be ignored. This keeps consistent state between restarts. This requires the config to be loaded.

func UpdateUser

func UpdateUser(
	ctx context.Context,
	db *pgxpool.Pool,
	userListID types.UserListName,
	teamNum types.TeamNum,
	user types.User,
) error

UpdateUser performs a password change request. This performs no validation. Will cause an error if invalid input is given. This query can only update the password in an existing row.

Types

type AllUsers

type AllUsers map[types.TeamNum]map[types.UserListName][]types.User

func GetAllUsers

func GetAllUsers(ctx context.Context, db *pgxpool.Pool) (AllUsers, error)

Jump to

Keyboard shortcuts

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