forked from free-lancers/electricity_bill_calc_service
		
	enhance(security):增加用户是否仅是运维用户的判断。
This commit is contained in:
		| @@ -54,3 +54,13 @@ func ManagementAuthorize(c *gin.Context) { | ||||
| 	} | ||||
| 	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() | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user