Skip to content

Commit

Permalink
Hide the diagnostic component when not in Developer mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mitch-b committed Jan 19, 2025
1 parent ad7cb9e commit 9d40f20
Showing 1 changed file with 40 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,50 @@
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject IWebAssemblyHostEnvironment HostEnvironment

<div class="session-information">
<div class="header" @onclick="ToggleDetails">
<h3>Session Information</h3>
<p>
<strong>Render Mode:</strong> @RendererInfo.Name
<span style="margin-left: 10px;">
@if (RendererInfo.IsInteractive)
{
<span class="badge bg-success">Interactive</span>
}
else
{
<span class="badge bg-warning">Static</span>
}
</span>
</p>
</div>
<div class="details" style="display:@(showDetails ? "block" : "none")">
@if (user == null || string.IsNullOrWhiteSpace(user?.Identity?.Name))
{
<p>No user information available.</p>
}
else if (user.Identity is not null)
{
<p><strong>User:</strong> @user.Identity.Name</p>
<p><strong>Is Authenticated:</strong> @user.Identity.IsAuthenticated</p>
<p><strong>Authentication Type:</strong> @user.Identity.AuthenticationType</p>
@if (HostEnvironment.IsDevelopment())
{
<div class="session-information">
<div class="header" @onclick="ToggleDetails">
<h3>Session Information</h3>
<p>
<button class="toggle-button" @onclick="ToggleClaims">Toggle Claims</button>
</p>
<div class="claims" style="display:@(showClaims ? "block" : "none")">
<ul>
@foreach (var claim in user.Claims)
<strong>Render Mode:</strong> @RendererInfo.Name
<span style="margin-left: 10px;">
@if (RendererInfo.IsInteractive)
{
<span class="badge bg-success">Interactive</span>
}
else
{
<li>@claim.Type: @claim.Value</li>
<span class="badge bg-warning">Static</span>
}
</ul>
</div>
}
</span>
</p>
</div>
<div class="details" style="display:@(showDetails ? "block" : "none")">
@if (user == null || string.IsNullOrWhiteSpace(user?.Identity?.Name))
{
<p>No user information available.</p>
}
else if (user.Identity is not null)
{
<p><strong>User:</strong> @user.Identity.Name</p>
<p><strong>Is Authenticated:</strong> @user.Identity.IsAuthenticated</p>
<p><strong>Authentication Type:</strong> @user.Identity.AuthenticationType</p>
<p>
<button class="toggle-button" @onclick="ToggleClaims">Toggle Claims</button>
</p>
<div class="claims" style="display:@(showClaims ? "block" : "none")">
<ul>
@foreach (var claim in user.Claims)
{
<li>@claim.Type: @claim.Value</li>
}
</ul>
</div>
}
</div>
</div>
</div>
}

@code {
private ClaimsPrincipal? user;
Expand Down

0 comments on commit 9d40f20

Please sign in to comment.