Documentation
¶
Overview ¶
Package users is the accounts of the multi mode: the sign-up, and the routes an admin runs the others with.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(db bun.IDB) http.HandlerFunc
Delete deletes an account for good, with all its data: DELETE /api/users/{id}. @Summary Delete an account and all its data @Tags users @Param id path string true "Account id" @Success 204 @Failure 400 {object} respond.Failure @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 404 {object} respond.Failure @Router /api/users/{id} [delete]
func List ¶
func List(db bun.IDB) http.HandlerFunc
List gives every account, by name: GET /api/users. @Summary List the accounts @Tags users @Produce json @Success 200 {array} domain.User @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 404 {object} respond.Failure @Router /api/users [get]
func Modes ¶
func Modes(mode domain.ServerMode) http.HandlerFunc
Modes tells the login and sign-up pages how the server runs, without a session: GET /api/add-user. @Summary How the server runs: its mode and how accounts are created @Tags users @Produce json @Success 200 {object} domain.ServerMode @Router /api/add-user [get]
func ResetPassword ¶
func ResetPassword(db bun.IDB) http.HandlerFunc
ResetPassword gives an account a random password, in the answer only, and logs its sessions out: POST /api/users/{id}/password. @Summary Reset the password of an account @Tags users @Produce json @Param id path string true "Account id" @Success 200 {object} users.Reset @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 404 {object} respond.Failure @Router /api/users/{id}/password [post]
func Signup ¶
func Signup(db bun.IDB, mode domain.ServerMode) http.HandlerFunc
Signup creates an account and logs it in, without a session: POST /api/signup, in the multi mode only. It needs an invitation in the invitation mode, but for the first account of a base, which becomes admin. Its tries count with the wrong passwords of the address (throttle.Passwords): an invitation cannot be guessed either. In the public mode the accounts of an address count too (throttle.Signups): a few, then it waits longer at each one. @Summary Create an account and log it in @Tags users @Accept json @Produce json @Param body body createuser.Input true "body" @Success 200 {object} createsession.Result @Failure 400 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 404 {object} respond.Failure @Failure 429 {object} respond.Failure @Router /api/signup [post]