-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.go
45 lines (40 loc) · 1.17 KB
/
user.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
44
45
package gauth
import "strings"
type AuthUser struct {
UID string `json:"uid"`
Username string `json:"username"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Blog string `json:"blog"`
Company string `json:"company"`
Location string `json:"location"`
Email string `json:"email"`
Remark string `json:"remark"`
Gender AuthUserGender `json:"gender"`
Source string `json:"source"`
Token AuthToken `json:"token"`
RawUserInfo string `json:"raw_user_info"`
SnapshotUser bool `json:"snapshot_user"`
}
type AuthUserGender int8
const (
GenderMale AuthUserGender = 1
GenderFemale AuthUserGender = 0
GenderUnknown AuthUserGender = -1
)
func GetRealGender(originalGender string) AuthUserGender {
if originalGender == "" || strings.EqualFold(originalGender, "UNKNOWN") {
return GenderUnknown
}
males := map[string]bool{
"m": true,
"男": true,
"1": true,
"male": true,
}
_, ok := males[strings.ToLower(originalGender)]
if ok {
return GenderMale
}
return GenderFemale
}