Rewrite identity and access management
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -21,11 +21,11 @@ import (
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -41,24 +41,8 @@ type (
|
||||
}
|
||||
|
||||
TrustCenters []*TrustCenter
|
||||
|
||||
ErrTrustCenterNotFound struct {
|
||||
Identifier string
|
||||
}
|
||||
|
||||
ErrTrustCenterAlreadyExists struct {
|
||||
message string
|
||||
}
|
||||
)
|
||||
|
||||
func (e ErrTrustCenterNotFound) Error() string {
|
||||
return fmt.Sprintf("trust center not found: %q", e.Identifier)
|
||||
}
|
||||
|
||||
func (e ErrTrustCenterAlreadyExists) Error() string {
|
||||
return e.message
|
||||
}
|
||||
|
||||
func (tc *TrustCenter) CursorKey(orderBy TrustCenterOrderField) page.CursorKey {
|
||||
switch orderBy {
|
||||
case TrustCenterOrderFieldCreatedAt:
|
||||
@@ -239,9 +223,7 @@ INSERT INTO trust_centers (
|
||||
var pgErr *pgconn.PgError
|
||||
if errors.As(err, &pgErr) {
|
||||
if pgErr.Code == "23505" && pgErr.ConstraintName == "trust_centers_slug_key" {
|
||||
return &ErrTrustCenterAlreadyExists{
|
||||
message: fmt.Sprintf("trust center with slug %q already exists", tc.Slug),
|
||||
}
|
||||
return ErrResourceAlreadyExists
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("cannot insert trust center: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user