/
identity.go
40 lines (32 loc) · 922 Bytes
/
identity.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
package users
import (
"time"
"github.com/jinzhu/gorm"
)
type AuthIdentity struct {
gorm.Model
Provider string // phone, email, wechat, github...
UID string
EncryptedPassword string
AuthInfo AuthInfo
UserID string
State string // unconfirmed, confirmed, expired
Password string `gorm:"-"`
PasswordConfirmation string `gorm:"-"`
}
////////////////////////////////////////////////////////////////////////////////
type SignLog struct {
UserAgent string
At *time.Time
IP string
}
type AuthInfo struct {
PhoneVerificationCode string
PhoneVerificationCodeExpiry *time.Time
PhoneConfirmedAt *time.Time
UnconfirmedPhone string // only use when changing phone number
EmailConfirmedAt *time.Time
UnconfirmedEmail string // only use when changing email
SignInCount uint
SignLogs []SignLog
}