account

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AccountActive indicates a confirmed account with a valid login
	AccountActive = 1
	// AccountLoggedOut indicates a confirmed account without a valid login
	AccountLoggedOut = 0
	// AccountDeactivated indicates an account that has been deactivated due to
	// e.g. account deletion or UserID swap
	AccountDeactivated = -1
	// AccountBlocked signals an issue with the account that needs intervention
	AccountBlocked = -2
	// AccountUnconfirmed well guess what?
	AccountUnconfirmed = -3
)

Variables

This section is empty.

Functions

func UpdateAccount

func UpdateAccount(ctx context.Context, account *Account) error

Types

type Account

type Account struct {
	Realm    string `json:"realm"`     // KEY
	UserID   string `json:"user_id"`   // KEY external id for the entity e.g. email for a user
	ClientID string `json:"client_id"` // a unique id within [realm,user_id]
	// status and other metadata
	Status int `json:"status"` // default == AccountUnconfirmed
	// login auditing
	LastLogin  int64  `json:"-"`
	LoginCount int    `json:"-"`
	LoginFrom  string `json:"-"`
	// internal
	Ext1      string `json:"-"` // universal field, used as needed. e.g to confirm the account and then to request the real token
	Ext2      string `json:"-"`
	Expires   int64  `json:"-"` // 0 == never
	Confirmed int64  `json:"-"`
	Created   int64  `json:"-"`
	Updated   int64  `json:"-"`
}

Account represents an account for a user or client (e.g. API, bot)

func CreateAccount

func CreateAccount(ctx context.Context, realm, userID string, expires int) (*Account, error)

CreateAccount creates an new account within a given realm

func FindAccountByToken

func FindAccountByToken(ctx context.Context, token string) (*Account, error)

FindAccountByToken retrieves an account bases on either the temporary token or the auth token

func FindAccountByUserID

func FindAccountByUserID(ctx context.Context, realm, userID string) (*Account, error)

FindAccountUserID retrieves an account bases on the user id

func LookupAccount

func LookupAccount(ctx context.Context, realm, clientID string) (*Account, error)

LookupAccount retrieves an account within a given realm

func ResetAccountChallenge

func ResetAccountChallenge(ctx context.Context, acc *Account, expires int) (*Account, error)

ResetAccountChallenge creates a new confirmation token and resets the timer

Jump to

Keyboard shortcuts

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