-
Notifications
You must be signed in to change notification settings - Fork 265
/
Copy pathuser.go
84 lines (74 loc) · 2.22 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* @Copyright Reserved By Janusec (https://www.janusec.com/).
* @Author: U2
* @Date: 2023-04-02 19:54:41
*/
package models
import "database/sql"
// AuthUser used for Authentication in Memory
type AuthUser struct {
UserID int64 `json:"user_id,string"`
Username string `json:"username"`
Logged bool `json:"logged"`
IsSuperAdmin bool `json:"is_super_admin"`
IsCertAdmin bool `json:"is_cert_admin"`
IsAppAdmin bool `json:"is_app_admin"`
NeedModifyPWD bool `json:"need_modify_pwd"`
// v1.2.2
TOTPKey string `json:"totp_key"`
TOTPVerified bool `json:"totp_verified"`
}
// AppUser used for DB Storage
type AppUser struct {
ID int64 `json:"id,string"`
Username string `json:"username"`
HashPwd string `json:"-"`
Salt string `json:"-"`
Email string `json:"email"`
IsSuperAdmin bool `json:"is_super_admin"`
IsCertAdmin bool `json:"is_cert_admin"`
IsAppAdmin bool `json:"is_app_admin"`
NeedModifyPWD bool `json:"need_modify_pwd"`
}
// FrontAppUser used for updating app user, receive from front end
type FrontAppUser struct {
ID int64 `json:"id,string"`
Username string `json:"username"`
Password string `json:"password"`
Email string `json:"email"`
IsSuperAdmin bool `json:"is_super_admin"`
IsCertAdmin bool `json:"is_cert_admin"`
IsAppAdmin bool `json:"is_app_admin"`
NeedModifyPWD bool `json:"need_modify_pwd"`
}
// QueryAppUser not include password and salt
type QueryAppUser struct {
ID int64
Username string
Email sql.NullString
IsSuperAdmin bool
IsCertAdmin bool
IsAppAdmin bool
NeedModifyPWD bool
}
// TOTP Authenticator
type TOTP struct {
ID int64 `json:"id,string"`
UID string `json:"uid"`
TOTPKey string `json:"totp_key"`
TOTPVerified bool `json:"totp_verified"`
}
type LoginUser struct {
Username string `json:"username"`
Password string `json:"passwd"`
TOTPKey string `json:"totp_key"`
}
type APILoginUserRequest struct {
Action string `json:"action"`
Object *LoginUser `json:"object"`
}
type APITOTPVerifyRequest struct {
Action string `json:"action"`
UID string `json:"uid"`
Code string `json:"code"`
}