feat(backend): hide soft deleted users in API responses

This commit is contained in:
Sam 2023-03-08 14:04:26 +01:00
parent ff3d612b06
commit 1687f04410
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
3 changed files with 16 additions and 0 deletions

View file

@ -77,6 +77,10 @@ func (s *Server) getMember(w http.ResponseWriter, r *http.Request) error {
return err
}
if u.DeletedAt != nil {
return server.APIError{Code: server.ErrMemberNotFound}
}
fields, err := s.DB.MemberFields(ctx, m.ID)
if err != nil {
return err
@ -96,6 +100,10 @@ func (s *Server) getUserMember(w http.ResponseWriter, r *http.Request) error {
}
}
if u.DeletedAt != nil {
return server.APIError{Code: server.ErrUserNotFound}
}
m, err := s.DB.UserMember(ctx, u.ID, chi.URLParam(r, "memberRef"))
if err != nil {
return server.APIError{

View file

@ -44,6 +44,10 @@ func (s *Server) getUserMembers(w http.ResponseWriter, r *http.Request) error {
}
}
if u.DeletedAt != nil {
return server.APIError{Code: server.ErrUserNotFound}
}
ms, err := s.DB.UserMembers(ctx, u.ID)
if err != nil {
return err

View file

@ -104,6 +104,10 @@ func (s *Server) getUser(w http.ResponseWriter, r *http.Request) error {
return err
}
if u.DeletedAt != nil {
return server.APIError{Code: server.ErrUserNotFound}
}
fields, err := s.DB.UserFields(ctx, u.ID)
if err != nil {
log.Errorf("Error getting user fields: %v", err)