@@ -7,7 +7,6 @@ import ( | |||||
"applet/app/e" | "applet/app/e" | ||||
"applet/app/enum" | "applet/app/enum" | ||||
"applet/app/utils" | "applet/app/utils" | ||||
"fmt" | |||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
"time" | "time" | ||||
) | ) | ||||
@@ -15,7 +14,6 @@ import ( | |||||
func UserInfo(c *gin.Context) { | func UserInfo(c *gin.Context) { | ||||
//1、获取用户信息 | //1、获取用户信息 | ||||
userInfo := svc.GetUser(c) | userInfo := svc.GetUser(c) | ||||
fmt.Println(">>>>>>>>>>>>>userInfo", userInfo) | |||||
//2、获取用户身份信息 | //2、获取用户身份信息 | ||||
userIdentityDb := db.UserIdentityDb{} | userIdentityDb := db.UserIdentityDb{} | ||||
userIdentityDb.Set(userInfo.Id) | userIdentityDb.Set(userInfo.Id) | ||||
@@ -20,6 +20,10 @@ func Auth(c *gin.Context) { | |||||
return | return | ||||
} | } | ||||
} | } | ||||
if user == nil { | |||||
e.OutErr(c, e.ERR_NOT_AUTH, "当前用户信息失效") | |||||
return | |||||
} | |||||
// 将当前请求的username信息保存到请求的上下文c上 | // 将当前请求的username信息保存到请求的上下文c上 | ||||
c.Set("user", user) | c.Set("user", user) | ||||
c.Next() | c.Next() | ||||
@@ -5,7 +5,6 @@ import ( | |||||
"applet/app/db" | "applet/app/db" | ||||
"applet/app/db/model" | "applet/app/db/model" | ||||
"errors" | "errors" | ||||
"fmt" | |||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
"strings" | "strings" | ||||
"time" | "time" | ||||
@@ -13,7 +12,6 @@ import ( | |||||
func GetUser(c *gin.Context) *model.User { | func GetUser(c *gin.Context) *model.User { | ||||
user, _ := c.Get("user") | user, _ := c.Get("user") | ||||
fmt.Println("user>>>>>>>>>", user) | |||||
if user == nil { | if user == nil { | ||||
return &model.User{ | return &model.User{ | ||||
Id: 0, | Id: 0, | ||||