Updated to GVA v2.5.6

This commit is contained in:
Mohamed Hassan
2023-08-03 12:49:44 +03:00
36 changed files with 1070 additions and 428 deletions
+14
View File
@@ -72,3 +72,17 @@ func GetUserInfo(c *gin.Context) *systemReq.CustomClaims {
return waitUse
}
}
// GetUserName 从Gin的Context中获取从jwt解析出来的用户名
func GetUserName(c *gin.Context) string {
if claims, exists := c.Get("claims"); !exists {
if cl, err := GetClaims(c); err != nil {
return ""
} else {
return cl.Username
}
} else {
waitUse := claims.(*systemReq.CustomClaims)
return waitUse.Username
}
}