Inital project setup
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
@using Microsoft.AspNetCore.Authentication
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using MudBlazor
|
||||
@using OpenArchival.Blazor.Data
|
||||
@using MudBlazor.StaticInput
|
||||
|
||||
@inject SignInManager<ApplicationUser> SignInManager
|
||||
@inject IdentityRedirectManager RedirectManager
|
||||
|
||||
@if (externalLogins.Length == 0)
|
||||
{
|
||||
<MudAlert Variant="Variant.Text" Severity="Severity.Warning">There are no external authentication services configured.</MudAlert>
|
||||
<MudText Typo="Typo.body1" Class="pt-4">
|
||||
See <MudLink Target="_blank" Href="https://go.microsoft.com/fwlink/?LinkID=532715">this article</MudLink>
|
||||
about setting up this ASP.NET application to support logging in via external services
|
||||
</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form class="form-horizontal" action="Account/PerformExternalLogin" method="post">
|
||||
<div>
|
||||
<AntiforgeryToken />
|
||||
<input type="hidden" name="ReturnUrl" value="@ReturnUrl" />
|
||||
<p>
|
||||
@foreach (var provider in externalLogins)
|
||||
{
|
||||
<button type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
|
||||
@code {
|
||||
private AuthenticationScheme[] externalLogins = [];
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
private string? ReturnUrl { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
externalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).ToArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
@inherits LayoutComponentBase
|
||||
@layout OpenArchival.Blazor.Components.Layout.MainLayout
|
||||
|
||||
<MudText Typo="Typo.h3" GutterBottom="true">Manage your account</MudText>
|
||||
|
||||
<MudGrid>
|
||||
<MudItem md="5">
|
||||
<MudText Typo="Typo.h6" GutterBottom="true">Change your account settings</MudText>
|
||||
<ManageNavMenu />
|
||||
</MudItem>
|
||||
<MudItem md="7">
|
||||
@Body
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -0,0 +1,25 @@
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using OpenArchival.Blazor.Data
|
||||
|
||||
@inject SignInManager<ApplicationUser> SignInManager
|
||||
|
||||
<MudNavMenu>
|
||||
<MudNavLink Href="Account/Manage" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Person">Profile</MudNavLink>
|
||||
<MudNavLink Href="Account/Manage/Email" Icon="@Icons.Material.Filled.Email">Email</MudNavLink>
|
||||
<MudNavLink Href="Account/Manage/ChangePassword" Icon="@Icons.Material.Filled.Lock">Password</MudNavLink>
|
||||
@if (hasExternalLogins)
|
||||
{
|
||||
<MudNavLink Href="Account/Manage/ExternalLogins" Icon="@Icons.Material.Filled.PhoneLocked">External logins</MudNavLink>
|
||||
}
|
||||
<MudNavLink Href="Account/Manage/TwoFactorAuthentication" Icon="@Icons.Material.Filled.LockClock">Two-factor authentication</MudNavLink>
|
||||
<MudNavLink Href="Account/Manage/PersonalData" Icon="@Icons.Material.Filled.PersonRemove">Personal data</MudNavLink>
|
||||
</MudNavMenu>
|
||||
|
||||
@code {
|
||||
private bool hasExternalLogins;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
@code {
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
NavigationManager.NavigateTo($"Account/Login?returnUrl={Uri.EscapeDataString(NavigationManager.Uri)}", forceLoad: true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<StatusMessage Message="@StatusMessage" />
|
||||
<h3>Recovery codes</h3>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<p>
|
||||
<strong>Put these codes in a safe place.</strong>
|
||||
</p>
|
||||
<p>
|
||||
If you lose your device and don't have the recovery codes you will lose access to your account.
|
||||
</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@foreach (var recoveryCode in RecoveryCodes)
|
||||
{
|
||||
<div>
|
||||
<code class="recovery-code">@recoveryCode</code>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string[] RecoveryCodes { get; set; } = [];
|
||||
|
||||
[Parameter]
|
||||
public string? StatusMessage { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
@if (!string.IsNullOrEmpty(DisplayMessage))
|
||||
{
|
||||
var severity = DisplayMessage.StartsWith("Error") ? Severity.Error : Severity.Success;
|
||||
|
||||
<MudAlert Variant="Variant.Outlined" Severity="@severity">@DisplayMessage</MudAlert>
|
||||
}
|
||||
|
||||
@code {
|
||||
private string? messageFromCookie;
|
||||
|
||||
[Parameter]
|
||||
public string? Message { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
private HttpContext HttpContext { get; set; } = default!;
|
||||
|
||||
private string? DisplayMessage => Message ?? messageFromCookie;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
messageFromCookie = HttpContext.Request.Cookies[IdentityRedirectManager.StatusCookieName];
|
||||
|
||||
if (messageFromCookie is not null)
|
||||
{
|
||||
HttpContext.Response.Cookies.Delete(IdentityRedirectManager.StatusCookieName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user