zjxpcyc 6 lat temu
rodzic
commit
7194a07327

+ 5
- 5
controllers/auth.go Wyświetl plik

@@ -38,11 +38,11 @@ func (c *BaseController) authenticate() {
38 38
 }
39 39
 
40 40
 // SetTokenExipre 设置 token 过期
41
-func (c *BaseController) SetTokenExipre() {
42
-	// token := c.Context.Get("token")
43
-	// if token != nil {
44
-	// 	c.serv.UpdateTokenExpire(token.(string))
45
-	// }
41
+func (c *BaseController) SetTokenExipre(uid string) {
42
+	token := c.Context.Get("token")
43
+	if token != nil {
44
+		c.serv.UpdateTokenExpire(token.(string), uid)
45
+	}
46 46
 
47 47
 	c.Context.Set("token", "")
48 48
 }

+ 1
- 1
controllers/base.go Wyświetl plik

@@ -74,7 +74,7 @@ func (c *BaseController) ResponseData(data interface{}, msg interface{}, code in
74 74
 
75 75
 	if status == http.StatusOK {
76 76
 		// 设置旧 token 过期
77
-		c.SetTokenExipre()
77
+		// c.SetTokenExipre()
78 78
 
79 79
 		// 生成新 token
80 80
 		c.CreateNewToken()

+ 2
- 0
controllers/user/user.go Wyświetl plik

@@ -206,7 +206,9 @@ func (c *UserController) SignIn() {
206 206
 
207 207
 // SignOut 用户登出
208 208
 func (c *UserController) SignOut() {
209
+	user := c.Context.Get("user").(model.SysUser)
209 210
 	c.Context.Set("user", nil)
211
+	c.SetTokenExipre(user.UserId)
210 212
 }
211 213
 
212 214
 // GetEnvVars 获取当前用户相关

+ 30
- 0
log/common.log Wyświetl plik

@@ -32,3 +32,33 @@
32 32
 2018/09/17 00:54:09 [E] 用户没有设置默认案场
33 33
 2018/09/17 00:54:12 [E] 用户没有设置默认案场
34 34
 2018/09/17 00:54:12 [E] 获取用户 Dashboard 配置失败: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group asc, sort_no asc' at line 10
35
+2018/09/17 01:03:25 [E] 用户没有设置默认案场
36
+2018/09/17 01:03:29 [E] 用户没有设置默认案场
37
+2018/09/17 01:04:50 [E] 用户没有设置默认案场
38
+2018/09/17 01:05:16 [E] 用户没有设置默认案场
39
+2018/09/17 01:07:14 [E] 用户没有设置默认案场
40
+2018/09/17 01:08:25 [E] 用户没有设置默认案场
41
+2018/09/17 01:09:52 [E] 用户没有设置默认案场
42
+2018/09/17 01:09:52 [E] 用户没有设置默认案场
43
+2018/09/17 01:11:11 [E] 用户没有设置默认案场
44
+2018/09/17 01:11:11 [E] 用户没有设置默认案场
45
+2018/09/17 01:11:24 [E] 用户没有设置默认案场
46
+2018/09/17 01:13:57 [E] 用户没有设置默认案场
47
+2018/09/17 01:14:19 [E] 用户没有设置默认案场
48
+2018/09/17 01:14:23 [E] 用户没有设置默认案场
49
+2018/09/17 01:14:23 [E] 获取用户 Dashboard 配置失败: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group asc, sort_no asc' at line 10
50
+2018/09/17 01:15:42 [E] 用户没有设置默认案场
51
+2018/09/17 01:15:42 [E] 用户没有设置默认案场
52
+2018/09/17 01:16:30 [E] 用户没有设置默认案场
53
+2018/09/17 01:16:30 [E] 用户没有设置默认案场
54
+2018/09/17 01:16:33 [E] 用户没有设置默认案场
55
+2018/09/17 01:16:42 [E] 用户没有设置默认案场
56
+2018/09/17 01:16:42 [E] 获取卡券统计数据失败: Error 1054: Unknown column 'a.receiving_type' in 'field list'
57
+2018/09/17 01:16:46 [E] 用户没有设置默认案场
58
+2018/09/17 01:16:46 [E] 用户没有设置默认案场
59
+2018/09/17 01:16:48 [E] 用户没有设置默认案场
60
+2018/09/17 01:16:49 [E] 用户没有设置默认案场
61
+2018/09/17 01:16:50 [E] 用户没有设置默认案场
62
+2018/09/17 01:16:50 [E] 获取商品订单统计数据失败: Error 1054: Unknown column 'create_date' in 'field list'
63
+2018/09/17 01:16:52 [E] 用户没有设置默认案场
64
+2018/09/17 01:16:52 [E] 用户没有设置默认案场

+ 1
- 0
models/model/sys_token_log.go Wyświetl plik

@@ -5,6 +5,7 @@ import "time"
5 5
 type SysTokenLog struct {
6 6
 	TokenId    int       `xorm:"not null pk autoincr INT(11)"`
7 7
 	Token      string    `xorm:"TEXT"`
8
+	Uid        string    `xorm:"VARCHAR(64)"`
8 9
 	Status     int       `xorm:"SMALLINT(6)"`
9 10
 	CreateDate time.Time `xorm:"DATETIME"`
10 11
 }

+ 1
- 1
models/statistics/other.go Wyświetl plik

@@ -53,7 +53,7 @@ func (m *StatisticsDAO) GetDashboardSetting(userID string, userTypes []string) (
53 53
 		FROM
54 54
 			ta_dashboard_setting t
55 55
 		JOIN td_statistics_comps s ON t.comp_id = s.comp_id
56
-		where (` + strings.Join(filters, " OR ") + ") AND status = ? order by group asc, sort_no asc"
56
+		where (` + strings.Join(filters, " OR ") + ") AND t.status = ? order by t.group asc, t.sort_no asc"
57 57
 
58 58
 	var settings []UserDashSetting
59 59
 	if err := m.db.SQL(sql, models.STATUS_NORMAL).Find(&settings); err != nil {

+ 4
- 3
models/sys.go Wyświetl plik

@@ -136,9 +136,10 @@ func GetWeChatConfig(org, cliType string) (*model.SysWechatConf, error) {
136 136
 }
137 137
 
138 138
 // InsertToken 插入 token 生成记录
139
-func InsertToken(token string) error {
139
+func InsertToken(token, uid string) error {
140 140
 	tk := model.SysTokenLog{
141 141
 		Token:      token,
142
+		Uid:        uid,
142 143
 		Status:     STATUS_NORMAL,
143 144
 		CreateDate: time.Now().Local(),
144 145
 	}
@@ -151,12 +152,12 @@ func InsertToken(token string) error {
151 152
 }
152 153
 
153 154
 // UpdateTokenExpire 设置 token 过期
154
-func UpdateTokenExpire(token string) error {
155
+func UpdateTokenExpire(token, uid string) error {
155 156
 	tk := model.SysTokenLog{
156 157
 		Status: STATUS_DEL,
157 158
 	}
158 159
 
159
-	if _, err := DBEngine.Cols("status").Where("token=?", token).Update(&tk); err != nil {
160
+	if _, err := DBEngine.Cols("status").Where("token=?", token).Or("uid=?", uid).Update(&tk); err != nil {
160 161
 		return err
161 162
 	}
162 163
 

+ 3
- 3
service/sys.go Wyświetl plik

@@ -111,7 +111,7 @@ func (s *SysServ) NewToken() string {
111 111
 
112 112
 	// 入库
113 113
 	if !token.Guest {
114
-		if err := models.InsertToken(tokenEncodeStr); err != nil {
114
+		if err := models.InsertToken(tokenEncodeStr, token.ID); err != nil {
115 115
 			utils.LogError("入库 Token 失败: " + err.Error())
116 116
 			return tokenEncodeStr
117 117
 		}
@@ -384,8 +384,8 @@ func (s *SysServ) getToken(gctx *context.Context) (*utils.JWTToken, error) {
384 384
 
385 385
 // UpdateTokenExpire 更新 token 为过期
386 386
 // 如果发生错误, 此处选择忽略
387
-func (s *SysServ) UpdateTokenExpire(token string) {
388
-	if err := models.UpdateTokenExpire(token); err != nil {
387
+func (s *SysServ) UpdateTokenExpire(token, uid string) {
388
+	if err := models.UpdateTokenExpire(token, uid); err != nil {
389 389
 		utils.LogError("更新 Token 过期失败: " + err.Error())
390 390
 	}
391 391
 }