enhance(security):增加用户是否仅是运维用户的判断。
This commit is contained in:
parent
e3e3587ab4
commit
e09bf9e728
|
@ -54,3 +54,13 @@ func ManagementAuthorize(c *gin.Context) {
|
||||||
}
|
}
|
||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 用于对用户会话进行是否运维用户的判断
|
||||||
|
// ! 通过该中间件以后,是可以保证上下文中一定具有用户会话信息的。
|
||||||
|
func OPSAuthorize(c *gin.Context) {
|
||||||
|
session, exists := c.Get("session")
|
||||||
|
if sess, ok := session.(*model.Session); !exists || !ok || sess.Type != 2 {
|
||||||
|
c.AbortWithStatus(http.StatusForbidden)
|
||||||
|
}
|
||||||
|
c.Next()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user