u
This commit is contained in:
1 parent
7552670e4a
commit
01ea998605
13 files changed
+173
-45
No files matched your search
@@ -21,6 +21,7 @@ func Auth() router.HandlerFunc {
|
||||
// 缺少登录信息
|
||||
if tokenHeader == "" || userIdHeader == "" || orgIDHeader == "" {
|
||||
response.Error(c).Code(response.CodeNoLogin).Send()
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,6 +29,7 @@ func Auth() router.HandlerFunc {
|
||||
parts := strings.Fields(tokenHeader)
|
||||
if len(parts) != 2 || strings.ToLower(parts[0]) != "bearer" {
|
||||
response.Error(c).Code(response.CodeInvalidToken).Send()
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -41,18 +43,21 @@ func Auth() router.HandlerFunc {
|
||||
default:
|
||||
response.Error(c).Code(response.CodeInvalidToken).Send()
|
||||
}
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// user_id 校验
|
||||
if claims.UserID != userIdHeader {
|
||||
response.Error(c).Code(response.CodeInvalidToken).Send()
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// org_id 校验
|
||||
if claims.OrgID != orgIDHeader {
|
||||
response.Error(c).Code(response.CodeInvalidToken).Send()
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -70,6 +75,8 @@ func Auth() router.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
c.Set("orgId", orgIDHeader)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user