users

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package users is the account routes an admin uses, and the self-service sign-up: the rest of an account's own routes are in login/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(db bun.IDB, store silo.Store) http.HandlerFunc

Delete deletes an account for good, with everything it holds: DELETE /api/users/{id}. @Summary Delete an account and all its data @Tags admin @Param id path string true "uuid" @Success 204 @Failure 400 {object} respond.Failure @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 404 {object} respond.Failure @Failure 500 {object} respond.Failure @Router /api/users/{id} [delete]

func Invite

func Invite(db bun.IDB) http.HandlerFunc

Invite creates an invitation link: POST /api/invites. Its token is in the answer and nowhere else. @Summary Create an invitation @Tags admin @Produce json @Success 201 {object} addinvite.Result @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 500 {object} respond.Failure @Router /api/invites [post]

func Invites

func Invites(db bun.IDB) http.HandlerFunc

Invites gives the invitations still usable: GET /api/invites. @Summary The invitations still usable @Tags admin @Produce json @Success 200 {array} domain.Invite @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 500 {object} respond.Failure @Router /api/invites [get]

func List

func List(db bun.IDB) http.HandlerFunc

List gives every account, for the admin panel: GET /api/users. @Summary Every account @Tags admin @Produce json @Success 200 {array} Account @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 500 {object} respond.Failure @Router /api/users [get]

func Modes

func Modes(db bun.IDB, mode string) http.HandlerFunc

Modes answers whether an account can be created, without a session: GET /api/add-user. @Summary Whether an account can be created @Tags account @Produce json @Param invite query string false "token of an invitation" @Success 200 {object} Mode @Failure 500 {object} respond.Failure @Router /api/add-user [get]

func ResetPassword

func ResetPassword(db bun.IDB) http.HandlerFunc

ResetPassword gives an account a random password and logs all its devices out: POST /api/users/{id}/password. The password is in the answer and nowhere else. @Summary Reset the password of an account @Tags admin @Param id path string true "uuid" @Produce json @Success 200 {object} Reset @Failure 400 {object} respond.Failure @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 404 {object} respond.Failure @Failure 500 {object} respond.Failure @Router /api/users/{id}/password [post]

func Revoke

func Revoke(db bun.IDB) http.HandlerFunc

Revoke makes an invitation unusable: DELETE /api/invites/{id}. @Summary Revoke an invitation @Tags admin @Param id path string true "uuid" @Success 204 @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 404 {object} respond.Failure @Failure 500 {object} respond.Failure @Router /api/invites/{id} [delete]

func Signup

func Signup(db bun.IDB, mode string) http.HandlerFunc

Signup creates an account without a session and logs it in: POST /api/signup. Allowed by an invitation, by the public mode, or on a base with no account yet, which the first account then runs. In the public mode an address waits longer after each account it creates. @Summary Create an account and log it in @Tags account @Accept json @Produce json @Param body body adduser.Input true "body" @Success 200 {object} createsession.Result @Failure 400 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 409 {object} respond.Failure @Failure 429 {object} respond.Failure @Failure 500 {object} respond.Failure @Router /api/signup [post]

func VersionHandler

func VersionHandler(db bun.IDB) http.HandlerFunc

Version is the server's build, for the admin to spot a mismatch with another deploy: GET /api/version. @Summary The server's build version @Tags admin @Produce json @Success 200 {object} Version @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 500 {object} respond.Failure @Router /api/version [get]

Types

type Account

type Account struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Admin     bool      `json:"admin"`
	CreatedAt time.Time `json:"created_at"`
}

Account is an account as the admin panel lists it: the settings of someone else are none of its business.

type Mode

type Mode struct {
	Mode string `json:"mode"` // one of domain.AddUserModes
	// Whether the sign-up page may create an account right now: the mode is public, the base has no account yet
	// (it is waiting for its host), or the invitation given is good.
	Allowed bool `json:"allowed"`
}

Mode tells the login and sign-up pages what the server allows.

type Reset

type Reset struct {
	Password string `json:"password"`
}

Reset is the new password of an account: it goes to the admin once, the base keeping only its hash.

type Version

type Version struct {
	Version string `json:"version"`
}

Version is the server's build, for the admin panel.

Jump to

Keyboard shortcuts

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