fix(postgres): keep every organisation an active owner
This commit is contained in:
8 files changed
+95
-4
No files matched your search
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/access"
|
||||
"github.com/samcharles93/archie-core/internal/domain/identity"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
)
|
||||
|
||||
type identityRequest struct {
|
||||
@@ -112,7 +113,7 @@ func writeIdentityError(w http.ResponseWriter, err error) {
|
||||
switch {
|
||||
case errors.Is(err, identity.ErrNotFound):
|
||||
code = http.StatusNotFound
|
||||
case errors.Is(err, identity.ErrConflict):
|
||||
case errors.Is(err, identity.ErrConflict), errors.Is(err, org.ErrLastOwner):
|
||||
code = http.StatusConflict
|
||||
case errors.Is(err, identity.ErrInvalid), errors.Is(err, identity.ErrIllegalTransition), errors.Is(err, identity.ErrSystemImmutable):
|
||||
code = http.StatusBadRequest
|
||||
|
||||
@@ -399,7 +399,8 @@ func writeOrgError(w http.ResponseWriter, err error) {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
case errors.Is(err, org.ErrOrgNotFound):
|
||||
http.Error(w, err.Error(), http.StatusNotFound)
|
||||
case errors.Is(err, org.ErrOrgExists), errors.Is(err, org.ErrWorkspaceExists), errors.Is(err, org.ErrMembershipExists):
|
||||
case errors.Is(err, org.ErrOrgExists), errors.Is(err, org.ErrWorkspaceExists), errors.Is(err, org.ErrMembershipExists),
|
||||
errors.Is(err, org.ErrLastOwner):
|
||||
http.Error(w, err.Error(), http.StatusConflict)
|
||||
default:
|
||||
writeControlPlaneError(w, err)
|
||||
|
||||
Reference in new issue
Block a user