mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: remove demo checks
This commit is contained in:
@@ -314,14 +314,6 @@ 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 {
|
||||
@@ -372,10 +364,6 @@ 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,
|
||||
|
@@ -130,10 +130,6 @@ func (s *APIV2Service) UpdateUser(ctx context.Context, request *apiv2pb.UpdateUs
|
||||
return nil, status.Errorf(codes.NotFound, "user not found")
|
||||
}
|
||||
|
||||
if s.Profile.Mode == "demo" && user.Username == "memos-demo" {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "unauthorized to update user in demo mode")
|
||||
}
|
||||
|
||||
currentTs := time.Now().Unix()
|
||||
update := &store.UpdateUser{
|
||||
ID: user.ID,
|
||||
@@ -203,10 +199,6 @@ func (s *APIV2Service) DeleteUser(ctx context.Context, request *apiv2pb.DeleteUs
|
||||
return nil, status.Errorf(codes.NotFound, "user not found")
|
||||
}
|
||||
|
||||
if s.Profile.Mode == "demo" && user.Username == "memos-demo" {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "unauthorized to delete this user in demo mode")
|
||||
}
|
||||
|
||||
if err := s.Store.DeleteUser(ctx, &store.DeleteUser{
|
||||
ID: user.ID,
|
||||
}); err != nil {
|
||||
|
Reference in New Issue
Block a user