login

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 13 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 login is the session: log in, log out, and who is asking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EditPassword added in v0.8.0

func EditPassword(db bun.IDB) http.HandlerFunc

EditPassword changes the password of the account logged in and logs its other devices out: PATCH /api/me/password. @Summary Change the password of the account logged in @Tags session @Accept json @Param body body editpassword.Input true "body" @Success 204 @Failure 400 {object} respond.Failure @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 429 {object} respond.Failure @Router /api/me/password [patch]

func Handler

func Handler(db bun.IDB, mode domain.ServerMode) http.HandlerFunc

Handler logs in: POST /api/login. The session token goes in an HttpOnly cookie, in the body only when the input asks it (the CLI). The multi mode needs the account's name. @Summary Log in @Tags session @Accept json @Produce json @Param body body createsession.Input true "body" @Success 200 {object} createsession.Result @Failure 400 {object} respond.Failure @Failure 401 {object} respond.Failure @Failure 429 {object} respond.Failure @Router /api/login [post]

func Logout

func Logout(db bun.IDB) http.HandlerFunc

Logout logs this device out: POST /api/logout. @Summary Log out @Tags session @Success 204 @Failure 401 {object} respond.Failure @Router /api/logout [post]

func Me

func Me(db bun.IDB, mode domain.ServerMode) http.HandlerFunc

Me is who asks: GET /api/me. @Summary Who is asking @Tags session @Produce json @Success 200 {object} login.MeResult @Failure 401 {object} respond.Failure @Router /api/me [get]

func Rename added in v0.8.0

func Rename(db bun.IDB) http.HandlerFunc

Rename changes the name of the account logged in, in the multi mode: PATCH /api/me/name. @Summary Rename the account logged in @Tags session @Accept json @Param body body renameuser.Input true "body" @Success 204 @Failure 400 {object} respond.Failure @Failure 401 {object} respond.Failure @Failure 403 {object} respond.Failure @Failure 404 {object} respond.Failure @Router /api/me/name [patch]

Types

type MeResult

type MeResult struct {
	Kind     domain.TokenKind `json:"kind" enums:"session,api,oauth"`
	Name     string           `json:"name,omitempty" binding:"optional"` // the token's, for an API token or an OAuth connection
	User     string           `json:"user"`                              // the account's name
	Admin    bool             `json:"admin"`                             // the account manages the others, in the multi mode
	Mode     string           `json:"mode" enums:"single,multi"`
	ReadOnly bool             `json:"read_only"`
	Version  string           `json:"version"`
}

MeResult is who asks: the kind of its token, whether it only reads, its account and the server's mode.

Jump to

Keyboard shortcuts

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