mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-01 22:33:30 +08:00
fix: 修改只读模式提示
This commit is contained in:
@@ -12,7 +12,6 @@ var LocalFS embed.FS
|
||||
var (
|
||||
ErrPermission = web.NewBadRequestErr("err-permission")
|
||||
ErrUserNotFound = web.NewBadRequestErr("err-user-not-found")
|
||||
ErrReadOnly = web.NewBadRequestErr("err-read-only")
|
||||
ErrPassword = web.NewBadRequestErr("err-password")
|
||||
ErrInviteCodeInvalid = web.NewBadRequestErr("err-invite-code-invalid")
|
||||
ErrEmailInvalid = web.NewBadRequestErr("err-email-invalid")
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
[err-permission]
|
||||
other = "无权操作"
|
||||
|
||||
[err-read-only]
|
||||
other = "只读模式"
|
||||
|
||||
[err-user-not-found]
|
||||
other = "用户不存在"
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"github.com/chaitin/MonkeyCode/backend/config"
|
||||
"github.com/chaitin/MonkeyCode/backend/errcode"
|
||||
)
|
||||
|
||||
type ReadOnlyMiddleware struct {
|
||||
@@ -21,7 +20,10 @@ func (m *ReadOnlyMiddleware) Guard() echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
if m.cfg.ReadOnly && c.Request().Method != http.MethodGet {
|
||||
return errcode.ErrReadOnly
|
||||
return c.JSON(http.StatusOK, echo.Map{
|
||||
"code": -1,
|
||||
"message": "只读模式下不支持该操作",
|
||||
})
|
||||
}
|
||||
return next(c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user