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:
Lincoln Nogueira
2024-01-31 02:16:31 -03:00
committed by GitHub
parent 49e3eb107c
commit 52539fc130
5 changed files with 43 additions and 2 deletions

View File

@ -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 {