Files
RUSTDESK-AP-SERVER-SUNLIX/http/middleware/admin_privilege.go

23 lines
462 B
Go

package middleware
import (
"github.com/gin-gonic/gin"
"github.com/lejianwen/rustdesk-api/v2/http/response"
"github.com/lejianwen/rustdesk-api/v2/service"
)
// AdminPrivilege ...
func AdminPrivilege() gin.HandlerFunc {
return func(c *gin.Context) {
u := service.AllService.UserService.CurUser(c)
if !service.AllService.UserService.IsAdmin(u) {
response.Fail(c, 403, response.TranslateMsg(c, "NoAccess"))
c.Abort()
return
}
c.Next()
}
}