refactor(model):固化用户类型为枚举。

This commit is contained in:
徐涛
2022-08-23 22:39:42 +08:00
parent 1c4132e2e7
commit 14ffd0e9fb
3 changed files with 11 additions and 5 deletions

View File

@@ -45,7 +45,7 @@ func EnterpriseAuthorize(c *gin.Context) {
if !exists || session == nil {
c.AbortWithStatus(http.StatusForbidden)
}
if sess, ok := session.(*model.Session); !ok || sess.Type != 0 {
if sess, ok := session.(*model.Session); !ok || sess.Type != model.USER_TYPE_ENT {
c.AbortWithStatus(http.StatusForbidden)
}
c.Next()
@@ -58,7 +58,7 @@ func ManagementAuthorize(c *gin.Context) {
if !exists || session == nil {
c.AbortWithStatus(http.StatusForbidden)
}
if sess, ok := session.(*model.Session); !ok || (sess.Type != 1 && sess.Type != 2) {
if sess, ok := session.(*model.Session); !ok || (sess.Type != model.USER_TYPE_SUP && sess.Type != model.USER_TYPE_OPS) {
c.AbortWithStatus(http.StatusForbidden)
}
c.Next()
@@ -71,7 +71,7 @@ func OPSAuthorize(c *gin.Context) {
if !exists {
c.AbortWithStatus(http.StatusForbidden)
}
if sess, ok := session.(*model.Session); !ok || sess.Type != 2 {
if sess, ok := session.(*model.Session); !ok || sess.Type != model.USER_TYPE_OPS {
c.AbortWithStatus(http.StatusForbidden)
}
c.Next()