Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
9ecc26187e
3 changed files with 4 additions and 4 deletions
  1. +0
    -2
      app/customer/hdl/hdl_user.go
  2. +4
    -0
      app/customer/mw/mw_customer_auth.go
  3. +0
    -2
      app/customer/svc/svc_auth.go

+ 0
- 2
app/customer/hdl/hdl_user.go View File

@@ -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)


+ 4
- 0
app/customer/mw/mw_customer_auth.go View File

@@ -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()


+ 0
- 2
app/customer/svc/svc_auth.go View File

@@ -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,


Loading…
Cancel
Save