-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admin session results are no longer cached (#509)
Co-authored-by: Ivan Lieckens <[email protected]>
- Loading branch information
1 parent
b7f2feb
commit 5190e09
Showing
4 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
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
24 changes: 24 additions & 0 deletions
24
headapps/MvpSite/MvpSite.Rendering/Helpers/MvpSelectionsApiHelper.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,24 @@ | ||
using System.Net; | ||
using Mvp.Selections.Client; | ||
using Mvp.Selections.Client.Models; | ||
using Mvp.Selections.Domain; | ||
|
||
namespace MvpSite.Rendering.Helpers; | ||
|
||
public class MvpSelectionsApiHelper(MvpSelectionsApiClient client) | ||
{ | ||
public async Task<bool> IsCurrentUserAnAdmin() | ||
{ | ||
bool isAdmin = false; | ||
if (await client.IsAuthenticatedAsync()) | ||
{ | ||
Response<User> currentUserResponse = await client.GetCurrentUserAsync(); | ||
if (currentUserResponse is { StatusCode: HttpStatusCode.OK, Result: not null }) | ||
{ | ||
isAdmin = currentUserResponse.Result.HasRight(Right.Admin); | ||
} | ||
} | ||
|
||
return isAdmin; | ||
} | ||
} |
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