feat: meta manage api

This commit is contained in:
Noah Hsu
2022-06-26 19:09:28 +08:00
parent acd4083399
commit 4cef3adc90
10 changed files with 120 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ package middlewares
import (
"github.com/alist-org/alist/v3/internal/db"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/server/common"
"github.com/gin-gonic/gin"
)
@@ -36,3 +37,13 @@ func Auth(c *gin.Context) {
c.Set("user", user)
c.Next()
}
func AuthAdmin(c *gin.Context) {
user := c.MustGet("user").(*model.User)
if !user.IsAdmin() {
common.ErrorStrResp(c, "You are not an admin", 403)
c.Abort()
} else {
c.Next()
}
}