forked from free-lancers/electricity_bill_calc_service
feat(god):基本完成天神模式所使用的数据服务。
This commit is contained in:
@@ -76,3 +76,16 @@ func OPSAuthorize(c *gin.Context) {
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
|
||||
// 用于对用户会话进行是否核心运维用户的判断
|
||||
// ! 通过该中间件以后,是可以保证上下文中一定具有用户会话信息的。
|
||||
func SingularityAuthorize(c *gin.Context) {
|
||||
session, exists := c.Get("session")
|
||||
if !exists {
|
||||
c.AbortWithStatus(http.StatusForbidden)
|
||||
}
|
||||
if sess, ok := session.(*model.Session); !ok || sess.Type != model.USER_TYPE_OPS || sess.Uid != "000" {
|
||||
c.AbortWithStatus(http.StatusForbidden)
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
|
Reference in New Issue
Block a user