Documentation ¶
Index ¶
- type Credentials
- func (c *Credentials) Confirm(uid types.Uid, method string) error
- func (c *Credentials) Del(uid types.Uid, method, value string) error
- func (c *Credentials) Fail(uid types.Uid, method string) error
- func (c *Credentials) GetActive(uid types.Uid, method string) (*types.Credential, error)
- func (c *Credentials) GetAll(uid types.Uid, method string, validatedOnly bool) ([]types.Credential, error)
- func (c *Credentials) Upsert(cred *types.Credential) (bool, error)
- type CredentialsArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials struct {
// contains filtered or unexported fields
}
func NewCredentials ¶
func NewCredentials(ca CredentialsArgs) *Credentials
func (*Credentials) Confirm ¶
func (c *Credentials) Confirm(uid types.Uid, method string) error
Confirm marks given credential method as confirmed.
func (*Credentials) Del ¶
func (c *Credentials) Del(uid types.Uid, method, value string) error
Del deletes either credentials of the given user. If method is blank all credentials
are removed. If value is blank all credentials of the given method are removed.
func (*Credentials) Fail ¶
func (c *Credentials) Fail(uid types.Uid, method string) error
Fail increments failure count of the given validation method.
func (*Credentials) GetActive ¶
func (c *Credentials) GetActive(uid types.Uid, method string) (*types.Credential, error)
GetActive returns currently active unvalidated credential of the given user and method.
func (*Credentials) GetAll ¶
func (c *Credentials) GetAll(uid types.Uid, method string, validatedOnly bool) ([]types.Credential, error)
GetAll returns credential records for the given user and method, all or validated only.
func (*Credentials) Upsert ¶
func (c *Credentials) Upsert(cred *types.Credential) (bool, error)
Upsert adds or updates a validation record. Returns true if inserted, false if updated.
1. if credential is validated:
1.1 Hard-delete unconfirmed equivalent record, if exists.
1.2 Insert new. Report error if duplicate.
2. if credential is not validated:
2.1 Check if validated equivalent exist. If so, report an error.
2.2 Soft-delete all unvalidated records of the same method.
2.3 Undelete existing credential. Return if successful.
2.4 Insert new credential record.
type CredentialsArgs ¶
type CredentialsArgs struct { DB *pgxpool.Pool Utils *utils.Utils UGen *types.UidGenerator Cfg *config.StorePostgresConfig }