mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
655 B
29 lines
655 B
// Copyright 2022 ROC. All rights reserved.
|
|
// Use of this source code is governed by a MIT style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package chain
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/rocboss/paopao-ce/internal/core/ms"
|
|
"github.com/rocboss/paopao-ce/pkg/app"
|
|
)
|
|
|
|
func Admin() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
if user, exist := c.Get("USER"); exist {
|
|
if userModel, ok := user.(*ms.User); ok {
|
|
if userModel.Status == ms.UserStatusNormal && userModel.IsAdmin {
|
|
c.Next()
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
response := app.NewResponse(c)
|
|
response.ToErrorResponse(_errNoAdminPermission)
|
|
c.Abort()
|
|
}
|
|
}
|