增加演示模式功能

This commit is contained in:
dushixiang 2021-03-09 23:58:12 +08:00
parent dc9934bc9e
commit 8a73a71a0d
2 changed files with 8 additions and 0 deletions

View File

@ -182,6 +182,9 @@ func LogoutEndpoint(c echo.Context) error {
} }
func ConfirmTOTPEndpoint(c echo.Context) error { func ConfirmTOTPEndpoint(c echo.Context) error {
if global.Config.Demo {
return Fail(c, 0, "演示模式禁止修改密码")
}
account, _ := GetCurrentAccount(c) account, _ := GetCurrentAccount(c)
var confirmTOTP ConfirmTOTP var confirmTOTP ConfirmTOTP
@ -239,6 +242,9 @@ func ResetTOTPEndpoint(c echo.Context) error {
} }
func ChangePasswordEndpoint(c echo.Context) error { func ChangePasswordEndpoint(c echo.Context) error {
if global.Config.Demo {
return Fail(c, 0, "演示模式禁止修改密码")
}
account, _ := GetCurrentAccount(c) account, _ := GetCurrentAccount(c)
var changePassword ChangePassword var changePassword ChangePassword

View File

@ -9,6 +9,7 @@ import (
type Config struct { type Config struct {
Debug bool Debug bool
Demo bool
DB string DB string
Server *Server Server *Server
Mysql *Mysql Mysql *Mysql
@ -80,6 +81,7 @@ func SetupConfig() (*Config, error) {
}, },
ResetPassword: viper.GetString("reset-password"), ResetPassword: viper.GetString("reset-password"),
Debug: viper.GetBool("debug"), Debug: viper.GetBool("debug"),
Demo: viper.GetBool("demo"),
} }
return config, nil return config, nil