Rewrite identity and access management
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -21,10 +21,10 @@ import (
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -43,24 +43,8 @@ type (
|
||||
}
|
||||
|
||||
Assets []*Asset
|
||||
|
||||
ErrAssetNotFound struct {
|
||||
Identifier string
|
||||
}
|
||||
|
||||
ErrAssetAlreadyExists struct {
|
||||
message string
|
||||
}
|
||||
)
|
||||
|
||||
func (e ErrAssetNotFound) Error() string {
|
||||
return fmt.Sprintf("asset not found: %q", e.Identifier)
|
||||
}
|
||||
|
||||
func (e ErrAssetAlreadyExists) Error() string {
|
||||
return e.message
|
||||
}
|
||||
|
||||
func (a *Asset) CursorKey(field AssetOrderField) page.CursorKey {
|
||||
switch field {
|
||||
case AssetOrderFieldCreatedAt:
|
||||
@@ -112,7 +96,7 @@ LIMIT 1;
|
||||
asset, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Asset])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrAssetNotFound{Identifier: assetID.String()}
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect asset: %w", err)
|
||||
@@ -162,7 +146,7 @@ LIMIT 1;
|
||||
asset, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Asset])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrAssetNotFound{Identifier: a.OwnerID.String()}
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect asset: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user