Fix failed to create policy and delete user PAT on postgres

Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
bcmmbaga
2024-11-07 18:34:07 +03:00
parent 2f7027194b
commit a23a09bba3
6 changed files with 89 additions and 60 deletions

View File

@@ -2430,16 +2430,17 @@ func newAccountWithId(ctx context.Context, store Store, accountID, userID, domai
return fmt.Errorf("failed to save group All: %w", err)
}
id := xid.New().String()
policyID := xid.New().String()
defaultPolicy := &Policy{
ID: id,
ID: policyID,
AccountID: accountID,
Name: DefaultPolicyName,
Description: DefaultPolicyDescription,
Enabled: true,
Rules: []*PolicyRule{
{
ID: id,
ID: xid.New().String(),
PolicyID: policyID,
Name: DefaultRuleName,
Description: DefaultRuleDescription,
Enabled: true,
@@ -2451,7 +2452,7 @@ func newAccountWithId(ctx context.Context, store Store, accountID, userID, domai
},
},
}
if err := transaction.SavePolicy(ctx, LockingStrengthUpdate, defaultPolicy); err != nil {
if err := transaction.CreatePolicy(ctx, LockingStrengthUpdate, defaultPolicy); err != nil {
return fmt.Errorf("failed to save default policy: %w", err)
}