chore: change permission check

This commit is contained in:
Noah Hsu
2022-06-29 17:08:31 +08:00
parent bf950ee6e1
commit a09a1b814b
6 changed files with 52 additions and 16 deletions

View File

@ -61,12 +61,12 @@ func AuthAdmin(c *gin.Context) {
}
}
func AuthWrite(c *gin.Context) {
func AuthManage(c *gin.Context) {
user := c.MustGet("user").(*model.User)
if !user.IsAdmin() && user.ReadOnly {
common.ErrorStrResp(c, "You have no write access", 403)
c.Abort()
} else {
if user.CanWrite() {
c.Next()
return
}
common.ErrorStrResp(c, "You have no write access", 403)
c.Abort()
}