From 8a73a71a0d3691818a7f8ac38704de04c3d769e8 Mon Sep 17 00:00:00 2001 From: dushixiang Date: Tue, 9 Mar 2021 23:58:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BC=94=E7=A4=BA=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/api/account.go | 6 ++++++ pkg/config/config.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/pkg/api/account.go b/pkg/api/account.go index 29e7a10..6b1956d 100644 --- a/pkg/api/account.go +++ b/pkg/api/account.go @@ -182,6 +182,9 @@ func LogoutEndpoint(c echo.Context) error { } func ConfirmTOTPEndpoint(c echo.Context) error { + if global.Config.Demo { + return Fail(c, 0, "演示模式禁止修改密码") + } account, _ := GetCurrentAccount(c) var confirmTOTP ConfirmTOTP @@ -239,6 +242,9 @@ func ResetTOTPEndpoint(c echo.Context) error { } func ChangePasswordEndpoint(c echo.Context) error { + if global.Config.Demo { + return Fail(c, 0, "演示模式禁止修改密码") + } account, _ := GetCurrentAccount(c) var changePassword ChangePassword diff --git a/pkg/config/config.go b/pkg/config/config.go index 4b1bc47..ec37f6a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -9,6 +9,7 @@ import ( type Config struct { Debug bool + Demo bool DB string Server *Server Mysql *Mysql @@ -80,6 +81,7 @@ func SetupConfig() (*Config, error) { }, ResetPassword: viper.GetString("reset-password"), Debug: viper.GetBool("debug"), + Demo: viper.GetBool("demo"), } return config, nil