通过grpc 调用的拦截
This commit is contained in:
parent
6680b593e5
commit
1916d879ce
|
|
@ -8,8 +8,8 @@ const (
|
|||
TokenName = "token"
|
||||
)
|
||||
|
||||
//AuthUser 用户认证拦截器
|
||||
func AuthUser() gin.HandlerFunc {
|
||||
//AuthJWT jwt用户认证拦截器
|
||||
func AuthJWT() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
// tokenString := c.GetHeader(TokenName)
|
||||
|
||||
|
|
@ -36,3 +36,55 @@ func AuthUser() gin.HandlerFunc {
|
|||
// c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
//WsUserAuth wodeschool用户角色验证拦截
|
||||
func WsUserAuth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
// tokenString := c.GetHeader(TokenName)
|
||||
// if tokenString == "" {
|
||||
// yy.RespUnauth(c, "token无效!", nil)
|
||||
// return
|
||||
// }
|
||||
|
||||
// srv, err := consul.FindServer("user")
|
||||
// if err != nil {
|
||||
// log.WithFields(log.Fields{
|
||||
// "func": "WsUserAuth",
|
||||
// }).Errorf("FindServer: %s", err.Error())
|
||||
// yy.RespUnauth(c, "用户认证失败,请检查后再试!", err)
|
||||
// return
|
||||
// }
|
||||
// defer srv.Close()
|
||||
// client := pb.NewCertificationClient(srv)
|
||||
// resp, err := client.Auth(context.Background(), &pb.CertificationAuthRequest{
|
||||
// PlatformID: conf.Golbal.PlatformID,
|
||||
// Token: tokenString,
|
||||
// })
|
||||
// if err != nil {
|
||||
// log.WithFields(log.Fields{
|
||||
// "func": "WsUserAuth",
|
||||
// }).Errorf("Auth: %s", err.Error())
|
||||
// yy.RespUnauth(c, "用户认证失败,请检查后再试!", err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// c.Set("user", yy.User{
|
||||
// UserID: resp.UserID,
|
||||
// PlatformID: resp.PlatformID,
|
||||
// OrgID: resp.OrgID,
|
||||
// Logname: resp.LogName,
|
||||
// Logpassword: "",
|
||||
// UserName: resp.UserName,
|
||||
// Avatar: resp.Avator,
|
||||
// Sex: resp.Sex,
|
||||
// RoleName: resp.RoleName,
|
||||
// Born: resp.Born,
|
||||
// Email: resp.Email,
|
||||
// Mobile: resp.Mobile,
|
||||
// RegionID: uint(resp.RegionID),
|
||||
// Address: resp.Address,
|
||||
// })
|
||||
|
||||
// c.Next()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue