Skip to content

Commit

Permalink
fix(app): Error details missing when user type is unknown (#1493)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->
Errors list is missing in error details when user type is unknown

## Related Issue(s)

- #1491 

## Verification

- [x] **Your** code builds clean without any errors or warnings
- [x] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved handling of unknown user types in the authentication
middleware, ensuring clearer response management.
  
- **Refactor**
- Enhanced code clarity by separating response retrieval and writing
processes in the user type validation logic.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
oskogstad authored Nov 19, 2024
1 parent dc7fc1f commit 9fbd2cf
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public async Task InvokeAsync(HttpContext context)
if (userType == UserIdType.Unknown)
{
context.Response.StatusCode = StatusCodes.Status403Forbidden;
await context.Response.WriteAsJsonAsync(context.GetResponseOrDefault(
var response = context.GetResponseOrDefault(
context.Response.StatusCode,
[
new("Type",
"The request was authenticated, but we were unable to determine valid user type (person or system user) in order to authorize the request.")
]
));
);
await context.Response.WriteAsJsonAsync(response, response.GetType());

return;
}
Expand Down

0 comments on commit 9fbd2cf

Please sign in to comment.