-
Notifications
You must be signed in to change notification settings - Fork 4
/
store.go
33 lines (26 loc) · 1.05 KB
/
store.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package passhash
import (
"context"
"errors"
)
// CredentialStore is an interfance for customizing Credential storage
type CredentialStore interface {
Store(*Credential) error
StoreContext(context.Context, *Credential) error
Load(UserID) (*Credential, error)
LoadContext(context.Context, UserID) (*Credential, error)
}
// DummyCredentialStore is a dummy CredentialStore that doesn't do anything
type DummyCredentialStore struct{}
// Store doesn't store anything
func (d DummyCredentialStore) Store(*Credential) error { return nil }
// StoreContext doesn't store anything
func (d DummyCredentialStore) StoreContext(context.Context, *Credential) error { return nil }
// Load only returns errors
func (d DummyCredentialStore) Load(UserID) (*Credential, error) {
return nil, errors.New("DummyCredentialStore does not support loading credentials")
}
// LoadContext only returns errors
func (d DummyCredentialStore) LoadContext(context.Context, UserID) (*Credential, error) {
return nil, errors.New("DummyCredentialStore does not support loading credentials")
}