mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
Enhance Guard and Form components with improved error handling and debugging
- Added debug logging in the `Guard` class to track policy evaluations and conditions. - Updated error logging in the `Form` component to provide more context on invalid submissions. - Introduced state management for form errors in the `AuthRolesEdit` component, displaying alerts for invalid data submissions.
This commit is contained in:
@@ -203,14 +203,17 @@ export class Guard {
|
||||
// set the default effect of the role permission
|
||||
let allowed = rolePermission.effect === "allow";
|
||||
for (const policy of rolePermission.policies) {
|
||||
$console.debug("guard: checking policy", { policy: policy.toJSON(), ctx });
|
||||
// skip filter policies
|
||||
if (policy.content.effect === "filter") continue;
|
||||
|
||||
// if condition is met, check the effect
|
||||
const meets = policy.meetsCondition(ctx);
|
||||
if (meets) {
|
||||
$console.debug("guard: policy meets condition");
|
||||
// if deny, then break early
|
||||
if (policy.content.effect === "deny") {
|
||||
$console.debug("guard: policy is deny, setting allowed to false");
|
||||
allowed = false;
|
||||
break;
|
||||
|
||||
@@ -218,6 +221,8 @@ export class Guard {
|
||||
} else if (policy.content.effect === "allow") {
|
||||
allowed = true;
|
||||
}
|
||||
} else {
|
||||
$console.debug("guard: policy does not meet condition");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user