mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: prevent visitors from breaking demo (#2869)
* chore: add en-GB language
* chore: remove en-GB contents
* chore: prevent visitors from breaking demo
- prevent disabling password login
- prevent updating `memos-demo` user
- prevent setting additional style
- prevent setting additional script
- add some error feedback to system settings UI
* Revert "chore: add en-GB language"
This reverts commit 2716377b04
.
This commit is contained in:
@ -159,6 +159,16 @@ func (s *APIV1Service) CreateSystemSetting(c echo.Context) error {
|
||||
if err := systemSettingUpsert.Validate(); err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "invalid system setting").SetInternal(err)
|
||||
}
|
||||
if s.Profile.Mode == "demo" {
|
||||
switch systemSettingUpsert.Name {
|
||||
case SystemSettingAdditionalStyleName:
|
||||
return echo.NewHTTPError(http.StatusForbidden, "additional style is not allowed in demo mode")
|
||||
case SystemSettingAdditionalScriptName:
|
||||
return echo.NewHTTPError(http.StatusForbidden, "additional script is not allowed in demo mode")
|
||||
case SystemSettingDisablePasswordLoginName:
|
||||
return echo.NewHTTPError(http.StatusForbidden, "disabling password login is not allowed in demo mode")
|
||||
}
|
||||
}
|
||||
if systemSettingUpsert.Name == SystemSettingDisablePasswordLoginName {
|
||||
var disablePasswordLogin bool
|
||||
if err := json.Unmarshal([]byte(systemSettingUpsert.Value), &disablePasswordLogin); err != nil {
|
||||
|
Reference in New Issue
Block a user