feat: check role assignment

This commit is contained in:
2025-06-30 00:08:14 +02:00
parent f5c61bb6a0
commit 0c24ed9382
3 changed files with 32 additions and 4 deletions

View File

@ -199,11 +199,16 @@ func EnsureSystemPermissions(ctx context.Context, repo *repository.Queries) {
}
for _, perm := range role.Permissions {
if err := repo.AssignRolePermission(ctx, repository.AssignRolePermissionParams{
if _, exists := repo.GetRoleAssignment(ctx, repository.GetRoleAssignmentParams{
RoleID: found.ID,
Key: perm,
}); err != nil {
log.Fatalf("ERR: Failed to assign permission '%s' to SYSTEM role %s: %v\n", perm, found.Name, err)
}); exists != nil {
if err := repo.AssignRolePermission(ctx, repository.AssignRolePermissionParams{
RoleID: found.ID,
Key: perm,
}); err != nil {
log.Fatalf("ERR: Failed to assign permission '%s' to SYSTEM role %s: %v\n", perm, found.Name, err)
}
}
}
}