-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
43 lines (33 loc) · 803 Bytes
/
models.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
34
35
36
37
38
39
40
41
42
43
package main
import "github.com/go-webauthn/webauthn/webauthn"
type User struct {
ID []byte
DisplayName string
Name string
creds []webauthn.Credential
}
func (o *User) WebAuthnID() []byte {
return o.ID
}
func (o *User) WebAuthnName() string {
return o.Name
}
func (o *User) WebAuthnDisplayName() string {
return o.DisplayName
}
func (o *User) WebAuthnIcon() string {
return "https://pics.com/avatar.png"
}
func (o *User) WebAuthnCredentials() []webauthn.Credential {
return o.creds
}
func (o *User) AddCredential(credential *webauthn.Credential) {
o.creds = append(o.creds, *credential)
}
func (o *User) UpdateCredential(credential *webauthn.Credential) {
for i, c := range o.creds {
if string(c.ID) == string(credential.ID) {
o.creds[i] = *credential
}
}
}