Updated login view and allowed login via username only
parent
dd0f221a94
commit
a3843a2d16
|
@ -1,82 +1,49 @@
|
|||
@page
|
||||
@model LoginModel
|
||||
@{ Layout = "/Views/Shared/_LayoutBasic.cshtml"; }
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Log in";
|
||||
}
|
||||
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<section>
|
||||
<form id="account" method="post">
|
||||
<h2>Use a local account to log in.</h2>
|
||||
<hr />
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-floating">
|
||||
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" />
|
||||
<label asp-for="Input.Email" class="form-label"></label>
|
||||
<span asp-validation-for="Input.Email" class="text-danger"></span>
|
||||
<div class="page page-center">
|
||||
<div class="container-tight py-4">
|
||||
<div class="text-center mb-4">
|
||||
LANCommander
|
||||
</div>
|
||||
|
||||
<form id="account" method="post" class="card card-md" autocomplete="off">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title text-center mb-4">Login to your account</h2>
|
||||
|
||||
<div class="mb-3">
|
||||
<label asp-for="Input.UserName" class="form-label"></label>
|
||||
<input asp-for="Input.UserName" class="form-control" autocomplete="username" aria-required="true" />
|
||||
<span asp-validation-for="Input.UserName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input asp-for="Input.Password" class="form-control" autocomplete="current-password" aria-required="true" />
|
||||
|
||||
<div class="mb-2">
|
||||
<label asp-for="Input.Password" class="form-label"></label>
|
||||
<input asp-for="Input.Password" class="form-control" autocomplete="current-password" aria-required="true" />
|
||||
<span asp-validation-for="Input.Password" class="text-danger"></span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="checkbox">
|
||||
<label asp-for="Input.RememberMe" class="form-label">
|
||||
<input class="form-check-input" asp-for="Input.RememberMe" />
|
||||
@Html.DisplayNameFor(m => m.Input.RememberMe)
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="mb-2">
|
||||
<label asp-for="Input.RememberMe" class="form-check">
|
||||
<input class="form-check-input" asp-for="Input.RememberMe" />
|
||||
<span class="form-check-label">@Html.DisplayNameFor(m => m.Input.RememberMe)</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<button id="login-submit" type="submit" class="w-100 btn btn-lg btn-primary">Log in</button>
|
||||
|
||||
<div class="form-footer">
|
||||
<button id="login-submit" type="submit" class="btn btn-primary w-100">Sign in</button>
|
||||
</div>
|
||||
<div>
|
||||
<p>
|
||||
<a id="forgot-password" asp-page="./ForgotPassword">Forgot your password?</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-page="./Register" asp-route-returnUrl="@Model.ReturnUrl">Register as a new user</a>
|
||||
</p>
|
||||
<p>
|
||||
<a id="resend-confirmation" asp-page="./ResendEmailConfirmation">Resend email confirmation</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<div class="col-md-6 col-md-offset-2">
|
||||
<section>
|
||||
<h3>Use another service to log in.</h3>
|
||||
<hr />
|
||||
@{
|
||||
if ((Model.ExternalLogins?.Count ?? 0) == 0)
|
||||
{
|
||||
<div>
|
||||
<p>
|
||||
There are no external authentication services configured. See this <a href="https://go.microsoft.com/fwlink/?LinkID=532715">article
|
||||
about setting up this ASP.NET application to support logging in via external services</a>.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form id="external-account" asp-page="./ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="form-horizontal">
|
||||
<div>
|
||||
<p>
|
||||
@foreach (var provider in Model.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>
|
||||
}
|
||||
}
|
||||
</section>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="text-center text-muted mt-3">
|
||||
Don't have account yet? <a asp-page="./Register" asp-route-returnUrl="@Model.ReturnUrl" tabindex="-1">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -66,8 +66,9 @@ namespace LANCommander.Areas.Identity.Pages.Account
|
|||
/// directly from your code. This API may change or be removed in future releases.
|
||||
/// </summary>
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
public string Email { get; set; }
|
||||
[DataType(DataType.Text)]
|
||||
[Display(Name = "User Name")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
|
||||
|
@ -112,7 +113,7 @@ namespace LANCommander.Areas.Identity.Pages.Account
|
|||
{
|
||||
// This doesn't count login failures towards account lockout
|
||||
// To enable password failures to trigger account lockout, set lockoutOnFailure: true
|
||||
var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: false);
|
||||
var result = await _signInManager.PasswordSignInAsync(Input.UserName, Input.Password, Input.RememberMe, lockoutOnFailure: false);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
_logger.LogInformation("User logged in.");
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
<hr />
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-floating">
|
||||
<input asp-for="Input.Username" class="form-control" autocomplete="username" aria-required="true" />
|
||||
<label asp-for="Input.Username"></label>
|
||||
<span asp-validation-for="Input.Username" class="text-danger"></span>
|
||||
<input asp-for="Input.UserName" class="form-control" autocomplete="username" aria-required="true" />
|
||||
<label asp-for="Input.UserName"></label>
|
||||
<span asp-validation-for="Input.UserName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input asp-for="Input.Password" class="form-control" autocomplete="new-password" aria-required="true" />
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace LANCommander.Areas.Identity.Pages.Account
|
|||
/// </summary>
|
||||
[Required]
|
||||
[Display(Name = "Username")]
|
||||
public string Username { get; set; }
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
|
||||
|
@ -112,7 +112,7 @@ namespace LANCommander.Areas.Identity.Pages.Account
|
|||
{
|
||||
var user = CreateUser();
|
||||
|
||||
await _userStore.SetUserNameAsync(user, Input.Username, CancellationToken.None);
|
||||
await _userStore.SetUserNameAsync(user, Input.UserName, CancellationToken.None);
|
||||
var result = await _userManager.CreateAsync(user, Input.Password);
|
||||
|
||||
if (result.Succeeded)
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.8" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.11" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ builder.Services.AddDbContext<LANCommander.Data.DatabaseContext>(b =>
|
|||
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
||||
|
||||
builder.Services.AddDefaultIdentity<User>((IdentityOptions options) => {
|
||||
options.SignIn.RequireConfirmedAccount = true;
|
||||
options.SignIn.RequireConfirmedAccount = false;
|
||||
options.Password.RequireNonAlphanumeric = false;
|
||||
options.SignIn.RequireConfirmedEmail = false;
|
||||
}).AddEntityFrameworkStores<LANCommander.Data.DatabaseContext>();
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - LANCommander</title>
|
||||
<link href="~/css/tabler.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/js/tabler.min.js"></script>
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,48 @@
|
|||
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
for details on configuring this project to bundle and minify static web assets. */
|
||||
|
||||
a.navbar-brand {
|
||||
white-space: normal;
|
||||
text-align: center;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0077cc;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.border-top {
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
.border-bottom {
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.box-shadow {
|
||||
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||
}
|
||||
|
||||
button.accept-policy {
|
||||
font-size: 1rem;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
line-height: 60px;
|
||||
}
|
Loading…
Reference in New Issue