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:
@@ -316,6 +316,14 @@ func (s *APIV1Service) DeleteUser(c echo.Context) error {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Cannot delete current user")
|
||||
}
|
||||
|
||||
findUser, err := s.Store.GetUser(ctx, &store.FindUser{ID: &userID})
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find user").SetInternal(err)
|
||||
}
|
||||
if s.Profile.Mode == "demo" && findUser.Username == "memos-demo" {
|
||||
return echo.NewHTTPError(http.StatusForbidden, "Unauthorized to delete this user in demo mode")
|
||||
}
|
||||
|
||||
if err := s.Store.DeleteUser(ctx, &store.DeleteUser{
|
||||
ID: userID,
|
||||
}); err != nil {
|
||||
@@ -366,6 +374,10 @@ func (s *APIV1Service) UpdateUser(c echo.Context) error {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid update user request").SetInternal(err)
|
||||
}
|
||||
|
||||
if s.Profile.Mode == "demo" && *request.Username == "memos-demo" {
|
||||
return echo.NewHTTPError(http.StatusForbidden, "Unauthorized to update user in demo mode")
|
||||
}
|
||||
|
||||
currentTs := time.Now().Unix()
|
||||
userUpdate := &store.UpdateUser{
|
||||
ID: userID,
|
||||
|
Reference in New Issue
Block a user