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