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 ¶
- func Delete(db bun.IDB, store silo.Store) http.HandlerFunc
- func Invite(db bun.IDB) http.HandlerFunc
- func Invites(db bun.IDB) http.HandlerFunc
- func List(db bun.IDB) http.HandlerFunc
- func Modes(db bun.IDB, mode string) http.HandlerFunc
- func ResetPassword(db bun.IDB) http.HandlerFunc
- func Revoke(db bun.IDB) http.HandlerFunc
- func Signup(db bun.IDB, mode string) http.HandlerFunc
- func VersionHandler(db bun.IDB) http.HandlerFunc
- type Account
- type Mode
- type Reset
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
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.