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
No known key found for this signature in database
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 return err
} }
if u.DeletedAt != nil {
return server.APIError{Code: server.ErrMemberNotFound}
}
fields, err := s.DB.MemberFields(ctx, m.ID) fields, err := s.DB.MemberFields(ctx, m.ID)
if err != nil { if err != nil {
return err 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")) m, err := s.DB.UserMember(ctx, u.ID, chi.URLParam(r, "memberRef"))
if err != nil { if err != nil {
return server.APIError{ 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) ms, err := s.DB.UserMembers(ctx, u.ID)
if err != nil { if err != nil {
return err return err

View File

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