chore: common err resp log
This commit is contained in:
@ -4,7 +4,7 @@ import (
|
||||
"github.com/alist-org/alist/v3/internal/db"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/setting"
|
||||
common2 "github.com/alist-org/alist/v3/server/common"
|
||||
"github.com/alist-org/alist/v3/server/common"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -15,7 +15,7 @@ func Auth(c *gin.Context) {
|
||||
if token == setting.GetByKey("token") {
|
||||
admin, err := db.GetAdmin()
|
||||
if err != nil {
|
||||
common2.ErrorResp(c, err, 500)
|
||||
common.ErrorResp(c, err, 500)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
@ -26,7 +26,7 @@ func Auth(c *gin.Context) {
|
||||
if token == "" {
|
||||
guest, err := db.GetGuest()
|
||||
if err != nil {
|
||||
common2.ErrorResp(c, err, 500)
|
||||
common.ErrorResp(c, err, 500)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
@ -34,15 +34,15 @@ func Auth(c *gin.Context) {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
userClaims, err := common2.ParseToken(token)
|
||||
userClaims, err := common.ParseToken(token)
|
||||
if err != nil {
|
||||
common2.ErrorResp(c, err, 401, true)
|
||||
common.ErrorResp(c, err, 401)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
user, err := db.GetUserByName(userClaims.Username)
|
||||
if err != nil {
|
||||
common2.ErrorResp(c, err, 401)
|
||||
common.ErrorResp(c, err, 401)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
@ -53,7 +53,7 @@ func Auth(c *gin.Context) {
|
||||
func AuthAdmin(c *gin.Context) {
|
||||
user := c.MustGet("user").(*model.User)
|
||||
if !user.IsAdmin() {
|
||||
common2.ErrorStrResp(c, "You are not an admin", 403, true)
|
||||
common.ErrorStrResp(c, "You are not an admin", 403)
|
||||
c.Abort()
|
||||
} else {
|
||||
c.Next()
|
||||
|
Reference in New Issue
Block a user