-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed - Org App Session expiry redirect to home page stopped working (#…
…689)
- Loading branch information
1 parent
a5f7c33
commit c12e7bb
Showing
10 changed files
with
48 additions
and
53 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
Frontend/CO.CDP.OrganisationApp/AuthenticatedSessionAwareMiddleware.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using CO.CDP.OrganisationApp.Models; | ||
using CO.CDP.OrganisationApp.Pages; | ||
|
||
namespace CO.CDP.OrganisationApp; | ||
|
||
public class AuthenticatedSessionAwareMiddleware(RequestDelegate next, ISession session) | ||
{ | ||
public async Task Invoke(HttpContext context) | ||
{ | ||
var endpoint = context.GetEndpoint(); | ||
|
||
if (endpoint != null) | ||
{ | ||
if (endpoint.Metadata.GetMetadata<AuthenticatedSessionNotRequiredAttribute>() is null) | ||
{ | ||
if (context.User.Identity?.IsAuthenticated == false) | ||
{ | ||
context.Response.Redirect("/"); | ||
return; | ||
} | ||
|
||
var details = session.Get<UserDetails>(Session.UserDetailsKey); | ||
|
||
if (details == null) | ||
{ | ||
context.Response.Redirect("/"); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
await next.Invoke(context); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Frontend/CO.CDP.OrganisationApp/Pages/AuthenticatedSessionNotRequiredAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace CO.CDP.OrganisationApp.Pages; | ||
|
||
[AttributeUsage(AttributeTargets.Class)] | ||
public class AuthenticatedSessionNotRequiredAttribute : Attribute | ||
{ | ||
} |
42 changes: 0 additions & 42 deletions
42
Frontend/CO.CDP.OrganisationApp/Pages/AuthorisedSessionFilter.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters