Skip to content

Commit 19a030e

Browse files
author
James Blair
committed
fix: review feedback on ForbiddenResult and dashboard 403 handling
- Remove unnecessary 'new' keyword on Result<T>.Forbidden (CS0109 warning) - ForbiddenResult doc comment no longer references ProblemDetails (Kernel should be unconcerned with web serialization) - Dashboard checks for requiredIal in 403 response body, not just status code, to distinguish IAL-related 403 from other authorization failures
1 parent acb6c01 commit 19a030e

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/SEBT.Portal.Kernel/Result.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static Result<T> ValidationFailed(string key, IEnumerable<ValidationError
5757
public new static Result<T> DependencyFailed(DependencyFailedReason reason, string? message = null)
5858
=> new DependencyFailedResult<T>(reason, message);
5959

60-
public new static Result<T> Forbidden(string message, IDictionary<string, object?>? extensions = null)
60+
public static Result<T> Forbidden(string message, IDictionary<string, object?>? extensions = null)
6161
=> new ForbiddenResult<T>(message, extensions);
6262

6363
public T Value => this switch

src/SEBT.Portal.Kernel/Results/ForbiddenResult.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ public class ForbiddenResult(string message) : Result(false)
88
public class ForbiddenResult<T>(string message, IDictionary<string, object?>? extensions = null) : Result<T>(false)
99
{
1010
/// <summary>
11-
/// Additional structured data to include in the ProblemDetails response.
11+
/// Additional structured data describing why access was denied.
12+
/// The API layer determines how to serialize this (e.g., as ProblemDetails extensions).
1213
/// </summary>
1314
public IDictionary<string, object?> Extensions { get; } = extensions ?? new Dictionary<string, object?>();
1415

src/SEBT.Portal.Web/src/features/household/components/DashboardContent/DashboardContent.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ export function DashboardContent() {
2525
const { data, isLoading, isError, error } = useHouseholdData()
2626
const { setPageData, setUserData, trackEvent } = useDataLayer()
2727

28-
// 403 means the user's IAL is below the minimum required by their cases.
29-
// Redirect to ID proofing so they can reach the required level.
30-
const requiresProofing = error instanceof ApiError && error.status === 403
28+
// A 403 with requiredIal in the response body means the user's IAL is below
29+
// the minimum required by their cases. Redirect to ID proofing.
30+
const requiresProofing =
31+
error instanceof ApiError &&
32+
error.status === 403 &&
33+
'requiredIal' in ((error.data as Record<string, unknown>) ?? {})
3134
useEffect(() => {
3235
if (requiresProofing) {
3336
router.push('/login/id-proofing')

0 commit comments

Comments
 (0)