From 5f0170df9787c6f3ff17cc168b3f2e3f511453f6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 31 十月 2023 20:04:16 +0800
Subject: [PATCH] 支持职级降级的情况
---
utils/clamis.go | 24 ++++++------------------
1 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/utils/clamis.go b/utils/clamis.go
index 1e10801..305d0ce 100644
--- a/utils/clamis.go
+++ b/utils/clamis.go
@@ -22,30 +22,18 @@
return claims, err
}
-// GetUserID 浠嶨in鐨凜ontext涓幏鍙栦粠jwt瑙f瀽鍑烘潵鐨勭敤鎴稩D
-func GetUserID(c *gin.Context) string {
- if claims, exists := c.Get("claims"); !exists {
- if cl, err := GetClaims(c); err != nil {
- return ""
- } else {
- return cl.UserId
- }
- } else {
+func GetUserID(c *gin.Context) int {
+ if claims, exists := c.Get("claims"); exists {
waitUse := claims.(*request.CustomClaims)
- return waitUse.UserId
+ return waitUse.CrmUserId
}
+ return 0
}
-// GetUserInfo 浠嶨in鐨凜ontext涓幏鍙栦粠jwt瑙f瀽鍑烘潵鐨勭敤鎴蜂俊鎭�
func GetUserInfo(c *gin.Context) *request.CustomClaims {
- if claims, exists := c.Get("claims"); !exists {
- if cl, err := GetClaims(c); err != nil {
- return nil
- } else {
- return cl
- }
- } else {
+ if claims, exists := c.Get("claims"); exists {
waitUse := claims.(*request.CustomClaims)
return waitUse
}
+ return nil
}
--
Gitblit v1.8.0