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:
@@ -45,6 +45,9 @@ func (s *APIV2Service) UpdateWorkspaceProfile(ctx context.Context, request *apiv
|
||||
return nil, status.Errorf(codes.Internal, "failed to update allow_registration system setting: %v", err)
|
||||
}
|
||||
} else if field == "disable_password_login" {
|
||||
if s.Profile.Mode == "demo" {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "disabling password login is not allowed in demo mode")
|
||||
}
|
||||
_, err := s.Store.UpsertWorkspaceSetting(ctx, &store.WorkspaceSetting{
|
||||
Name: "disable-password-login",
|
||||
Value: strconv.FormatBool(request.WorkspaceProfile.DisablePasswordLogin),
|
||||
@@ -53,6 +56,9 @@ func (s *APIV2Service) UpdateWorkspaceProfile(ctx context.Context, request *apiv
|
||||
return nil, status.Errorf(codes.Internal, "failed to update disable_password_login system setting: %v", err)
|
||||
}
|
||||
} else if field == "additional_script" {
|
||||
if s.Profile.Mode == "demo" {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "additional script is not allowed in demo mode")
|
||||
}
|
||||
_, err := s.Store.UpsertWorkspaceSetting(ctx, &store.WorkspaceSetting{
|
||||
Name: "additional-script",
|
||||
Value: request.WorkspaceProfile.AdditionalScript,
|
||||
@@ -61,6 +67,9 @@ func (s *APIV2Service) UpdateWorkspaceProfile(ctx context.Context, request *apiv
|
||||
return nil, status.Errorf(codes.Internal, "failed to update additional_script system setting: %v", err)
|
||||
}
|
||||
} else if field == "additional_style" {
|
||||
if s.Profile.Mode == "demo" {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "additional style is not allowed in demo mode")
|
||||
}
|
||||
_, err := s.Store.UpsertWorkspaceSetting(ctx, &store.WorkspaceSetting{
|
||||
Name: "additional-style",
|
||||
Value: request.WorkspaceProfile.AdditionalStyle,
|
||||
|
Reference in New Issue
Block a user