createsession

package
v0.9.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: 8 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 createsession logs in: the name and password checked, a session made for the device.

Index

Constants

View Source
const Lifetime = 30 * 24 * time.Hour

Lifetime is how long a session lasts without use: each use starts it again (readtoken).

Variables

View Source
var ErrBadCredentials = domain.Unauthorized("wrong name or password")

Functions

func CheckPassword

func CheckPassword(ctx context.Context, db bun.IDB, name, pass string, multi bool) (string, error)

CheckPassword checks the name and password of an account and returns its id, in the same time whether the account exists or not: ErrBadCredentials either way, so the answer never tells which names exist. Without a name, the account is the base's only one, which the multi mode refuses. The OAuth consent checks it too, without a session.

func Process

func Process(ctx context.Context, db bun.IDB, input Input, multi bool) *run

Process logs in to the account of input, multi telling the server's mode (domain.ServerMode.Multi).

Types

type Input

type Input struct {
	// Name is the account's, any case: required in the multi mode, optional in the single one, where it must be the
	// one account's.
	Name     string `json:"name,omitempty" binding:"optional"`
	Password string `json:"password"`
	// Token asks the token in the answer too, for a client without cookies (the CLI): the web keeps it HttpOnly.
	Token bool `json:"token,omitempty" binding:"optional"`
}

type Result

type Result struct {
	Token     string    `json:"token,omitempty" binding:"optional"`
	ExpiresAt time.Time `json:"expires_at"`
}

Result is the new session: the token goes to the client, and only there.

Jump to

Keyboard shortcuts

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