auth.go
3.2 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package protocol
import "opp/models"
const (
LoginTypePassPord = "signInPassword"
LoginTypeSmdcode = "signInCaptcha"
)
const (
DeviceType = 1
)
const TokenExpire = 3600
const SmscodeDayLimitTime = 10 //短信验证码每天最多发10次
var Nums = []byte("0123456789")
type RequestHeader struct {
TimeStamp string
Uuid string
Sign string
DeviceType int
AppProject string
AccessToken string
Uid int64 //用户基本信息Id
CompanyId int64
UserId int64 //UserId 唯一标识,唯一关联所有用户信息(=user_company.id)
}
/*Login */
type LoginRequest struct {
Uid int64 `json:"uid" valid:"Required;"`
}
type LoginResponse struct {
AuthCode string `json:"authCode"`
}
/*统一用户中心登录*/
type UserCenterLoginRequest struct {
Phone string `json:"phone"`
PassWord string `json:"password"`
Code string `json:"code"`
GrantType string `json:"grantType" valid:"Required"`
ClientId string `json:"clientId" valid:"Required"`
}
type UserCenterLoginResponse struct {
Id int64 `json:"id"`
Phone string `json:"phone"`
NickName string `json:"nickname"`
Avatar string `json:"avatar"`
Token string `json:"token"`
Accid string `json:"accid"`
CustomerAccount string `json:"customerAccount"`
}
/*SmsCode*/
type SmsCodeRequest struct {
Phone string `json:"phone" valid:"Required;Mobile"`
Content string `json:"-"`
SendType string `json:"send_type"` //sms_login_code sms_change_mobile
}
type SmsCodeResponse struct {
Code string `json:"-"`
}
/*UpdateDevice*/
type UpdateDeviceRequest struct {
ClientId string `json:"clientId" valid:"Required"`
DeviceToken string `json:"deviceToken"`
}
type UpdateDeviceResponse struct {
}
/*AccessToken */
type AccessTokenRequest struct {
ClientId string `json:"clientId" valid:"Required"`
ClientSecret string `json:"clientSecret" valid:"Required"`
AuthCode string `json:"authCode" valid:"Required"`
}
type AccessTokenResponse struct {
RefreshToken string `json:"refreshToken"`
AccessToken string `json:"accessToken"`
ExpiresIn int `json:"expiresIn"`
}
/*RefreshToken */
type RefreshTokenRequest struct {
ClientId string `json:"clientId" valid:"Required"`
ClientSecret string `json:"clientSecret" valid:"Required"`
RefreshToken string `json:"refreshToken" valid:"Required"`
Uid int64 `json:"-"`
LoginType string `json:"-"`
}
type RefreshTokenResponse struct {
RefreshToken string `json:"refreshToken"`
AccessToken string `json:"accessToken"`
ExpiresIn int `json:"expiresIn"`
}
type Access struct {
Uid int64
Type string
AccessToken string
RefreshToken string
}
/*CheckToken */
type CheckTokenRequest struct {
Token string
}
type CheckTokenResponse struct {
IsValid bool //true:过期 false:没有过期
UserInfo *models.UserAuth
}
/*CheckUuid */
type CheckUuidRequest struct {
Uuid string
}
type CheckUuidResponse struct {
}
/*CheckIm */
type CheckImRequest struct {
Uid string
Uname string
Icon string
IsCreated bool
}
type CheckImResponse struct {
ImToken string //net im token
CsAccount int64 //客服id
}
/*Revoke */
type RevokeRequest struct {
}
type RevokeResponse struct {
}