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

@@ -399,7 +399,12 @@ func (am *DefaultAccountManager) SavePolicy(ctx context.Context, accountID, user
return fmt.Errorf("failed to increment network serial: %w", err)
}
if err = transaction.SavePolicy(ctx, LockingStrengthUpdate, policy); err != nil {
saveFunc := transaction.SavePolicy
if !isUpdate {
saveFunc = transaction.CreatePolicy
}
if err := saveFunc(ctx, LockingStrengthUpdate, policy); err != nil {
return fmt.Errorf("failed to save policy: %w", err)
}
return nil