committed by
GitHub
78 changed files with 1246 additions and 39849 deletions
@ -0,0 +1,16 @@ |
|||
namespace LINGYUN.Abp.Account |
|||
{ |
|||
/// <summary>
|
|||
/// 定义账户系统Url
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 定义在领域共享层,可以方便其他应用程序调用
|
|||
/// </remarks>
|
|||
public static class AccountUrlNames |
|||
{ |
|||
/// <summary>
|
|||
/// 邮件登录验证地址
|
|||
/// </summary>
|
|||
public static string MailLoginVerify { get; set; } = ""; |
|||
} |
|||
} |
|||
@ -1,9 +1,33 @@ |
|||
using Volo.Abp.Modularity; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Emailing; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Sms; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace LINGYUN.Abp.Account.Web |
|||
{ |
|||
[DependsOn(typeof(Volo.Abp.Account.Web.AbpAccountWebModule))] |
|||
[DependsOn( |
|||
typeof(AbpSmsModule), |
|||
typeof(AbpEmailingModule), |
|||
typeof(Volo.Abp.Account.Web.AbpAccountWebModule))] |
|||
public class AbpAccountWebModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<AbpAccountWebModule>(); |
|||
}); |
|||
|
|||
context.Services |
|||
.AddAuthorization(options => |
|||
{ |
|||
options |
|||
.AddPolicy("TwoFactorEnabled", policy => |
|||
{ |
|||
policy.RequireClaim("amr", "mfa"); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,7 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<RazorPage_SelectedScaffolderID>RazorPageScaffolder</RazorPage_SelectedScaffolderID> |
|||
<RazorPage_SelectedScaffolderCategoryPath>root/Common/RazorPage</RazorPage_SelectedScaffolderCategoryPath> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -0,0 +1,22 @@ |
|||
@page |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.Account.Localization |
|||
@model LINGYUN.Abp.Account.Web.Pages.Account.SendCodeModel |
|||
@inject IHtmlLocalizer<AccountResource> L |
|||
|
|||
<div class="card mt-3 shadow-sm rounded"> |
|||
<div class="card-body p-5"> |
|||
<h4>@L["SendTwoFactor"]</h4> |
|||
<form method="post" class="mt-4"> |
|||
<input asp-for="SendCodeInput.RememberMe" type="hidden" /> |
|||
<input asp-for="SendCodeInput.ReturnUrl" type="hidden" /> |
|||
<div class="form-group"> |
|||
<label asp-for="@L["SelectProvider"]"></label> |
|||
<abp-select asp-for="SendCodeInput.SelectedProvider" asp-items="Model.SendCodeInput.Providers"></abp-select> |
|||
</div> |
|||
<abp-button type="submit" button-type="Primary" class="btn-block btn-lg mt-3">@L["SendTwoFactorCode"]</abp-button> |
|||
</form> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
@ -0,0 +1,94 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.Rendering; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Account.Web.Pages.Account; |
|||
using Volo.Abp.Emailing; |
|||
using Volo.Abp.Sms; |
|||
|
|||
namespace LINGYUN.Abp.Account.Web.Pages.Account |
|||
{ |
|||
public class SendCodeModel : AccountPageModel |
|||
{ |
|||
[BindProperty] |
|||
public SendCodeInputModel SendCodeInput { get; set; } |
|||
|
|||
protected ISmsSender SmsSender { get; } |
|||
protected IEmailSender EmailSender { get; } |
|||
|
|||
public virtual IActionResult OnGet() |
|||
{ |
|||
SendCodeInput = new SendCodeInputModel(); |
|||
|
|||
return Page(); |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var user = await SignInManager.GetTwoFactorAuthenticationUserAsync(); |
|||
if (user == null) |
|||
{ |
|||
Alerts.Warning("双因素认证失败,用户未登录!"); |
|||
return Page(); |
|||
} |
|||
|
|||
if (SendCodeInput.SelectedProvider == "Authenticator") |
|||
{ |
|||
var verifyAuthenticatorCodeInput = new VerifyAuthenticatorCodeInputModel |
|||
{ |
|||
ReturnUrl = SendCodeInput.ReturnUrl, |
|||
RememberMe = SendCodeInput.RememberMe |
|||
}; |
|||
return RedirectToPage("VerifyAuthenticatorCode", verifyAuthenticatorCodeInput); |
|||
} |
|||
|
|||
var code = await UserManager.GenerateTwoFactorTokenAsync(user, SendCodeInput.SelectedProvider); |
|||
if (string.IsNullOrWhiteSpace(code)) |
|||
{ |
|||
Alerts.Warning("验证码生成失败,请联系系统管理员!"); |
|||
return Page(); |
|||
} |
|||
|
|||
var message = "Your security code is: " + code; |
|||
if (SendCodeInput.SelectedProvider == "Email") |
|||
{ |
|||
await EmailSender.SendAsync(await UserManager.GetEmailAsync(user), "Security Code", message); |
|||
} |
|||
else if (SendCodeInput.SelectedProvider == "Phone") |
|||
{ |
|||
await SmsSender.SendAsync(await UserManager.GetPhoneNumberAsync(user), message); |
|||
} |
|||
|
|||
var verifyCodeInput = new VerifyCodeInputModel |
|||
{ |
|||
Provider = SendCodeInput.SelectedProvider, |
|||
ReturnUrl = SendCodeInput.ReturnUrl, |
|||
RememberMe = SendCodeInput.RememberMe |
|||
}; |
|||
|
|||
return RedirectToPage("VerifyCode", verifyCodeInput); |
|||
} |
|||
} |
|||
|
|||
public class SendCodeInputModel |
|||
{ |
|||
public string SelectedProvider { get; set; } |
|||
|
|||
public ICollection<SelectListItem> Providers { get; set; } |
|||
|
|||
public string ReturnUrl { get; set; } |
|||
|
|||
public bool RememberMe { get; set; } |
|||
} |
|||
|
|||
public class TwoFactorInputModel |
|||
{ |
|||
public string SelectedProvider { get; set; } |
|||
|
|||
public ICollection<SelectListItem> Providers { get; set; } |
|||
|
|||
public string ReturnUrl { get; set; } |
|||
|
|||
public bool RememberMe { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
@page |
|||
@model LINGYUN.Abp.Account.Web.Pages.Account.UseRecoveryCodeModel |
|||
@{ |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
|
|||
namespace LINGYUN.Abp.Account.Web.Pages.Account |
|||
{ |
|||
public class UseRecoveryCodeModel : PageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
@page |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.Account.Localization |
|||
@model LINGYUN.Abp.Account.Web.Pages.Account.VerifyAuthenticatorCodeModel |
|||
@inject IHtmlLocalizer<AccountResource> L |
|||
|
|||
<form method="post" class="mt-4"> |
|||
<input asp-for="Input.RememberMe" type="hidden" /> |
|||
<div class="form-group"> |
|||
<label asp-for="Input.Code"></label> |
|||
<input asp-for="Input.Code" class="form-control" /> |
|||
<span asp-validation-for="Input.Code" class="text-danger"></span> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label asp-for="Input.RememberBrowser"></label> |
|||
<abp-input asp-for="Input.RememberBrowser" /> |
|||
</div> |
|||
<abp-button type="submit" button-type="Primary" class="btn-block btn-lg mt-3">@L["VerifyAuthenticatorCode"]</abp-button> |
|||
</form> |
|||
|
|||
@ -0,0 +1,55 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Account.Web.Pages.Account; |
|||
|
|||
namespace LINGYUN.Abp.Account.Web.Pages.Account |
|||
{ |
|||
public class VerifyAuthenticatorCodeModel : AccountPageModel |
|||
{ |
|||
[BindProperty] |
|||
public VerifyAuthenticatorCodeInputModel Input { get; set; } |
|||
|
|||
public virtual IActionResult OnGet() |
|||
{ |
|||
Input = new VerifyAuthenticatorCodeInputModel(); |
|||
|
|||
return Page(); |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var result = await SignInManager.TwoFactorAuthenticatorSignInAsync(Input.Code, Input.RememberMe, Input.RememberBrowser); |
|||
if (result.Succeeded) |
|||
{ |
|||
return RedirectSafely(Input.ReturnUrl); |
|||
} |
|||
if (result.IsLockedOut) |
|||
{ |
|||
Logger.LogWarning(7, "User account locked out."); |
|||
Alerts.Warning(L["UserLockedOutMessage"]); |
|||
return Page(); |
|||
} |
|||
else |
|||
{ |
|||
Alerts.Danger("ÊÚȨÂëÑéÖ¤ÎÞЧ!"); |
|||
return Page(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class VerifyAuthenticatorCodeInputModel |
|||
{ |
|||
[Required] |
|||
public string Code { get; set; } |
|||
|
|||
public string ReturnUrl { get; set; } |
|||
|
|||
[Display(Name = "Remember this browser?")] |
|||
public bool RememberBrowser { get; set; } |
|||
|
|||
[Display(Name = "Remember me?")] |
|||
public bool RememberMe { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
@page |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.Account.Localization |
|||
@model LINGYUN.Abp.Account.Web.Pages.Account.VerifyCodeModel |
|||
@inject IHtmlLocalizer<AccountResource> L |
|||
|
|||
<form method="post" class="mt-4"> |
|||
<input asp-for="Input.Provider" type="hidden" /> |
|||
<input asp-for="Input.RememberMe" type="hidden" /> |
|||
<div class="form-group"> |
|||
<label asp-for="Input.Code"></label> |
|||
<input asp-for="Input.Code" class="form-control" /> |
|||
<span asp-validation-for="Input.Code" class="text-danger"></span> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label asp-for="Input.RememberBrowser"></label> |
|||
<abp-input asp-for="Input.RememberBrowser" /> |
|||
</div> |
|||
<abp-button type="submit" button-type="Primary" class="btn-block btn-lg mt-3">@L["VerifyCode"]</abp-button> |
|||
</form> |
|||
@ -0,0 +1,65 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Account.Web.Pages.Account; |
|||
|
|||
namespace LINGYUN.Abp.Account.Web.Pages.Account |
|||
{ |
|||
public class VerifyCodeModel : AccountPageModel |
|||
{ |
|||
[BindProperty] |
|||
public VerifyCodeInputModel Input { get; set; } |
|||
|
|||
public virtual IActionResult OnGet() |
|||
{ |
|||
Input = new VerifyCodeInputModel(); |
|||
|
|||
return Page(); |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var user = await SignInManager.GetTwoFactorAuthenticationUserAsync(); |
|||
if (user == null) |
|||
{ |
|||
Alerts.Warning("双因素认证失败,用户未登录或已失效!"); |
|||
return Page(); |
|||
} |
|||
|
|||
var result = await SignInManager.TwoFactorSignInAsync(Input.Provider, Input.Code, Input.RememberMe, Input.RememberBrowser); |
|||
if (result.Succeeded) |
|||
{ |
|||
return RedirectSafely(Input.ReturnUrl); |
|||
} |
|||
if (result.IsLockedOut) |
|||
{ |
|||
Logger.LogWarning(7, "User account locked out."); |
|||
Alerts.Warning(L["UserLockedOutMessage"]); |
|||
return Page(); |
|||
} |
|||
else |
|||
{ |
|||
Alerts.Danger("授权码验证无效!"); |
|||
return Page(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class VerifyCodeInputModel |
|||
{ |
|||
[Required] |
|||
public string Provider { get; set; } |
|||
|
|||
[Required] |
|||
public string Code { get; set; } |
|||
|
|||
public string ReturnUrl { get; set; } |
|||
|
|||
[Display(Name = "Remember this browser?")] |
|||
public bool RememberBrowser { get; set; } |
|||
|
|||
[Display(Name = "Remember me?")] |
|||
public bool RememberMe { get; set; } |
|||
} |
|||
} |
|||
@ -1,71 +0,0 @@ |
|||
/* 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; |
|||
} |
|||
|
|||
/* Provide sufficient contrast against white background */ |
|||
a { |
|||
color: #0366d6; |
|||
} |
|||
|
|||
.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; |
|||
} |
|||
|
|||
/* Sticky footer styles |
|||
-------------------------------------------------- */ |
|||
html { |
|||
font-size: 14px; |
|||
} |
|||
@media (min-width: 768px) { |
|||
html { |
|||
font-size: 16px; |
|||
} |
|||
} |
|||
|
|||
.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; |
|||
} |
|||
|
|||
/* Sticky footer styles |
|||
-------------------------------------------------- */ |
|||
html { |
|||
position: relative; |
|||
min-height: 100%; |
|||
} |
|||
|
|||
body { |
|||
/* Margin bottom by footer height */ |
|||
margin-bottom: 60px; |
|||
} |
|||
.footer { |
|||
position: absolute; |
|||
bottom: 0; |
|||
width: 100%; |
|||
white-space: nowrap; |
|||
line-height: 60px; /* Vertically center the text there */ |
|||
} |
|||
|
Before Width: | Height: | Size: 31 KiB |
@ -1,4 +0,0 @@ |
|||
// 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.
|
|||
|
|||
// Write your Javascript code.
|
|||
@ -1,22 +0,0 @@ |
|||
The MIT License (MIT) |
|||
|
|||
Copyright (c) 2011-2018 Twitter, Inc. |
|||
Copyright (c) 2011-2018 The Bootstrap Authors |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in |
|||
all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|||
THE SOFTWARE. |
|||
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,331 +0,0 @@ |
|||
/*! |
|||
* Bootstrap Reboot v4.3.1 (https://getbootstrap.com/) |
|||
* Copyright 2011-2019 The Bootstrap Authors |
|||
* Copyright 2011-2019 Twitter, Inc. |
|||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
|||
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) |
|||
*/ |
|||
*, |
|||
*::before, |
|||
*::after { |
|||
box-sizing: border-box; |
|||
} |
|||
|
|||
html { |
|||
font-family: sans-serif; |
|||
line-height: 1.15; |
|||
-webkit-text-size-adjust: 100%; |
|||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); |
|||
} |
|||
|
|||
article, aside, figcaption, figure, footer, header, hgroup, main, nav, section { |
|||
display: block; |
|||
} |
|||
|
|||
body { |
|||
margin: 0; |
|||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; |
|||
font-size: 1rem; |
|||
font-weight: 400; |
|||
line-height: 1.5; |
|||
color: #212529; |
|||
text-align: left; |
|||
background-color: #fff; |
|||
} |
|||
|
|||
[tabindex="-1"]:focus { |
|||
outline: 0 !important; |
|||
} |
|||
|
|||
hr { |
|||
box-sizing: content-box; |
|||
height: 0; |
|||
overflow: visible; |
|||
} |
|||
|
|||
h1, h2, h3, h4, h5, h6 { |
|||
margin-top: 0; |
|||
margin-bottom: 0.5rem; |
|||
} |
|||
|
|||
p { |
|||
margin-top: 0; |
|||
margin-bottom: 1rem; |
|||
} |
|||
|
|||
abbr[title], |
|||
abbr[data-original-title] { |
|||
text-decoration: underline; |
|||
-webkit-text-decoration: underline dotted; |
|||
text-decoration: underline dotted; |
|||
cursor: help; |
|||
border-bottom: 0; |
|||
-webkit-text-decoration-skip-ink: none; |
|||
text-decoration-skip-ink: none; |
|||
} |
|||
|
|||
address { |
|||
margin-bottom: 1rem; |
|||
font-style: normal; |
|||
line-height: inherit; |
|||
} |
|||
|
|||
ol, |
|||
ul, |
|||
dl { |
|||
margin-top: 0; |
|||
margin-bottom: 1rem; |
|||
} |
|||
|
|||
ol ol, |
|||
ul ul, |
|||
ol ul, |
|||
ul ol { |
|||
margin-bottom: 0; |
|||
} |
|||
|
|||
dt { |
|||
font-weight: 700; |
|||
} |
|||
|
|||
dd { |
|||
margin-bottom: .5rem; |
|||
margin-left: 0; |
|||
} |
|||
|
|||
blockquote { |
|||
margin: 0 0 1rem; |
|||
} |
|||
|
|||
b, |
|||
strong { |
|||
font-weight: bolder; |
|||
} |
|||
|
|||
small { |
|||
font-size: 80%; |
|||
} |
|||
|
|||
sub, |
|||
sup { |
|||
position: relative; |
|||
font-size: 75%; |
|||
line-height: 0; |
|||
vertical-align: baseline; |
|||
} |
|||
|
|||
sub { |
|||
bottom: -.25em; |
|||
} |
|||
|
|||
sup { |
|||
top: -.5em; |
|||
} |
|||
|
|||
a { |
|||
color: #007bff; |
|||
text-decoration: none; |
|||
background-color: transparent; |
|||
} |
|||
|
|||
a:hover { |
|||
color: #0056b3; |
|||
text-decoration: underline; |
|||
} |
|||
|
|||
a:not([href]):not([tabindex]) { |
|||
color: inherit; |
|||
text-decoration: none; |
|||
} |
|||
|
|||
a:not([href]):not([tabindex]):hover, a:not([href]):not([tabindex]):focus { |
|||
color: inherit; |
|||
text-decoration: none; |
|||
} |
|||
|
|||
a:not([href]):not([tabindex]):focus { |
|||
outline: 0; |
|||
} |
|||
|
|||
pre, |
|||
code, |
|||
kbd, |
|||
samp { |
|||
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; |
|||
font-size: 1em; |
|||
} |
|||
|
|||
pre { |
|||
margin-top: 0; |
|||
margin-bottom: 1rem; |
|||
overflow: auto; |
|||
} |
|||
|
|||
figure { |
|||
margin: 0 0 1rem; |
|||
} |
|||
|
|||
img { |
|||
vertical-align: middle; |
|||
border-style: none; |
|||
} |
|||
|
|||
svg { |
|||
overflow: hidden; |
|||
vertical-align: middle; |
|||
} |
|||
|
|||
table { |
|||
border-collapse: collapse; |
|||
} |
|||
|
|||
caption { |
|||
padding-top: 0.75rem; |
|||
padding-bottom: 0.75rem; |
|||
color: #6c757d; |
|||
text-align: left; |
|||
caption-side: bottom; |
|||
} |
|||
|
|||
th { |
|||
text-align: inherit; |
|||
} |
|||
|
|||
label { |
|||
display: inline-block; |
|||
margin-bottom: 0.5rem; |
|||
} |
|||
|
|||
button { |
|||
border-radius: 0; |
|||
} |
|||
|
|||
button:focus { |
|||
outline: 1px dotted; |
|||
outline: 5px auto -webkit-focus-ring-color; |
|||
} |
|||
|
|||
input, |
|||
button, |
|||
select, |
|||
optgroup, |
|||
textarea { |
|||
margin: 0; |
|||
font-family: inherit; |
|||
font-size: inherit; |
|||
line-height: inherit; |
|||
} |
|||
|
|||
button, |
|||
input { |
|||
overflow: visible; |
|||
} |
|||
|
|||
button, |
|||
select { |
|||
text-transform: none; |
|||
} |
|||
|
|||
select { |
|||
word-wrap: normal; |
|||
} |
|||
|
|||
button, |
|||
[type="button"], |
|||
[type="reset"], |
|||
[type="submit"] { |
|||
-webkit-appearance: button; |
|||
} |
|||
|
|||
button:not(:disabled), |
|||
[type="button"]:not(:disabled), |
|||
[type="reset"]:not(:disabled), |
|||
[type="submit"]:not(:disabled) { |
|||
cursor: pointer; |
|||
} |
|||
|
|||
button::-moz-focus-inner, |
|||
[type="button"]::-moz-focus-inner, |
|||
[type="reset"]::-moz-focus-inner, |
|||
[type="submit"]::-moz-focus-inner { |
|||
padding: 0; |
|||
border-style: none; |
|||
} |
|||
|
|||
input[type="radio"], |
|||
input[type="checkbox"] { |
|||
box-sizing: border-box; |
|||
padding: 0; |
|||
} |
|||
|
|||
input[type="date"], |
|||
input[type="time"], |
|||
input[type="datetime-local"], |
|||
input[type="month"] { |
|||
-webkit-appearance: listbox; |
|||
} |
|||
|
|||
textarea { |
|||
overflow: auto; |
|||
resize: vertical; |
|||
} |
|||
|
|||
fieldset { |
|||
min-width: 0; |
|||
padding: 0; |
|||
margin: 0; |
|||
border: 0; |
|||
} |
|||
|
|||
legend { |
|||
display: block; |
|||
width: 100%; |
|||
max-width: 100%; |
|||
padding: 0; |
|||
margin-bottom: .5rem; |
|||
font-size: 1.5rem; |
|||
line-height: inherit; |
|||
color: inherit; |
|||
white-space: normal; |
|||
} |
|||
|
|||
progress { |
|||
vertical-align: baseline; |
|||
} |
|||
|
|||
[type="number"]::-webkit-inner-spin-button, |
|||
[type="number"]::-webkit-outer-spin-button { |
|||
height: auto; |
|||
} |
|||
|
|||
[type="search"] { |
|||
outline-offset: -2px; |
|||
-webkit-appearance: none; |
|||
} |
|||
|
|||
[type="search"]::-webkit-search-decoration { |
|||
-webkit-appearance: none; |
|||
} |
|||
|
|||
::-webkit-file-upload-button { |
|||
font: inherit; |
|||
-webkit-appearance: button; |
|||
} |
|||
|
|||
output { |
|||
display: inline-block; |
|||
} |
|||
|
|||
summary { |
|||
display: list-item; |
|||
cursor: pointer; |
|||
} |
|||
|
|||
template { |
|||
display: none; |
|||
} |
|||
|
|||
[hidden] { |
|||
display: none !important; |
|||
} |
|||
/*# sourceMappingURL=bootstrap-reboot.css.map */ |
|||
File diff suppressed because one or more lines are too long
@ -1,8 +0,0 @@ |
|||
/*! |
|||
* Bootstrap Reboot v4.3.1 (https://getbootstrap.com/) |
|||
* Copyright 2011-2019 The Bootstrap Authors |
|||
* Copyright 2011-2019 Twitter, Inc. |
|||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
|||
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) |
|||
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important} |
|||
/*# sourceMappingURL=bootstrap-reboot.min.css.map */ |
|||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,12 +0,0 @@ |
|||
Copyright (c) .NET Foundation. All rights reserved. |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use |
|||
these files except in compliance with the License. You may obtain a copy of the |
|||
License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software distributed |
|||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
|||
CONDITIONS OF ANY KIND, either express or implied. See the License for the |
|||
specific language governing permissions and limitations under the License. |
|||
@ -1,432 +0,0 @@ |
|||
// Unobtrusive validation support library for jQuery and jQuery Validate
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|||
// @version v3.2.11
|
|||
|
|||
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */ |
|||
/*global document: false, jQuery: false */ |
|||
|
|||
(function (factory) { |
|||
if (typeof define === 'function' && define.amd) { |
|||
// AMD. Register as an anonymous module.
|
|||
define("jquery.validate.unobtrusive", ['jquery-validation'], factory); |
|||
} else if (typeof module === 'object' && module.exports) { |
|||
// CommonJS-like environments that support module.exports
|
|||
module.exports = factory(require('jquery-validation')); |
|||
} else { |
|||
// Browser global
|
|||
jQuery.validator.unobtrusive = factory(jQuery); |
|||
} |
|||
}(function ($) { |
|||
var $jQval = $.validator, |
|||
adapters, |
|||
data_validation = "unobtrusiveValidation"; |
|||
|
|||
function setValidationValues(options, ruleName, value) { |
|||
options.rules[ruleName] = value; |
|||
if (options.message) { |
|||
options.messages[ruleName] = options.message; |
|||
} |
|||
} |
|||
|
|||
function splitAndTrim(value) { |
|||
return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g); |
|||
} |
|||
|
|||
function escapeAttributeValue(value) { |
|||
// As mentioned on http://api.jquery.com/category/selectors/
|
|||
return value.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1"); |
|||
} |
|||
|
|||
function getModelPrefix(fieldName) { |
|||
return fieldName.substr(0, fieldName.lastIndexOf(".") + 1); |
|||
} |
|||
|
|||
function appendModelPrefix(value, prefix) { |
|||
if (value.indexOf("*.") === 0) { |
|||
value = value.replace("*.", prefix); |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
function onError(error, inputElement) { // 'this' is the form element
|
|||
var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"), |
|||
replaceAttrValue = container.attr("data-valmsg-replace"), |
|||
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null; |
|||
|
|||
container.removeClass("field-validation-valid").addClass("field-validation-error"); |
|||
error.data("unobtrusiveContainer", container); |
|||
|
|||
if (replace) { |
|||
container.empty(); |
|||
error.removeClass("input-validation-error").appendTo(container); |
|||
} |
|||
else { |
|||
error.hide(); |
|||
} |
|||
} |
|||
|
|||
function onErrors(event, validator) { // 'this' is the form element
|
|||
var container = $(this).find("[data-valmsg-summary=true]"), |
|||
list = container.find("ul"); |
|||
|
|||
if (list && list.length && validator.errorList.length) { |
|||
list.empty(); |
|||
container.addClass("validation-summary-errors").removeClass("validation-summary-valid"); |
|||
|
|||
$.each(validator.errorList, function () { |
|||
$("<li />").html(this.message).appendTo(list); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
function onSuccess(error) { // 'this' is the form element
|
|||
var container = error.data("unobtrusiveContainer"); |
|||
|
|||
if (container) { |
|||
var replaceAttrValue = container.attr("data-valmsg-replace"), |
|||
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null; |
|||
|
|||
container.addClass("field-validation-valid").removeClass("field-validation-error"); |
|||
error.removeData("unobtrusiveContainer"); |
|||
|
|||
if (replace) { |
|||
container.empty(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
function onReset(event) { // 'this' is the form element
|
|||
var $form = $(this), |
|||
key = '__jquery_unobtrusive_validation_form_reset'; |
|||
if ($form.data(key)) { |
|||
return; |
|||
} |
|||
// Set a flag that indicates we're currently resetting the form.
|
|||
$form.data(key, true); |
|||
try { |
|||
$form.data("validator").resetForm(); |
|||
} finally { |
|||
$form.removeData(key); |
|||
} |
|||
|
|||
$form.find(".validation-summary-errors") |
|||
.addClass("validation-summary-valid") |
|||
.removeClass("validation-summary-errors"); |
|||
$form.find(".field-validation-error") |
|||
.addClass("field-validation-valid") |
|||
.removeClass("field-validation-error") |
|||
.removeData("unobtrusiveContainer") |
|||
.find(">*") // If we were using valmsg-replace, get the underlying error
|
|||
.removeData("unobtrusiveContainer"); |
|||
} |
|||
|
|||
function validationInfo(form) { |
|||
var $form = $(form), |
|||
result = $form.data(data_validation), |
|||
onResetProxy = $.proxy(onReset, form), |
|||
defaultOptions = $jQval.unobtrusive.options || {}, |
|||
execInContext = function (name, args) { |
|||
var func = defaultOptions[name]; |
|||
func && $.isFunction(func) && func.apply(form, args); |
|||
}; |
|||
|
|||
if (!result) { |
|||
result = { |
|||
options: { // options structure passed to jQuery Validate's validate() method
|
|||
errorClass: defaultOptions.errorClass || "input-validation-error", |
|||
errorElement: defaultOptions.errorElement || "span", |
|||
errorPlacement: function () { |
|||
onError.apply(form, arguments); |
|||
execInContext("errorPlacement", arguments); |
|||
}, |
|||
invalidHandler: function () { |
|||
onErrors.apply(form, arguments); |
|||
execInContext("invalidHandler", arguments); |
|||
}, |
|||
messages: {}, |
|||
rules: {}, |
|||
success: function () { |
|||
onSuccess.apply(form, arguments); |
|||
execInContext("success", arguments); |
|||
} |
|||
}, |
|||
attachValidation: function () { |
|||
$form |
|||
.off("reset." + data_validation, onResetProxy) |
|||
.on("reset." + data_validation, onResetProxy) |
|||
.validate(this.options); |
|||
}, |
|||
validate: function () { // a validation function that is called by unobtrusive Ajax
|
|||
$form.validate(); |
|||
return $form.valid(); |
|||
} |
|||
}; |
|||
$form.data(data_validation, result); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
$jQval.unobtrusive = { |
|||
adapters: [], |
|||
|
|||
parseElement: function (element, skipAttach) { |
|||
/// <summary>
|
|||
/// Parses a single HTML element for unobtrusive validation attributes.
|
|||
/// </summary>
|
|||
/// <param name="element" domElement="true">The HTML element to be parsed.</param>
|
|||
/// <param name="skipAttach" type="Boolean">[Optional] true to skip attaching the
|
|||
/// validation to the form. If parsing just this single element, you should specify true.
|
|||
/// If parsing several elements, you should specify false, and manually attach the validation
|
|||
/// to the form when you are finished. The default is false.</param>
|
|||
var $element = $(element), |
|||
form = $element.parents("form")[0], |
|||
valInfo, rules, messages; |
|||
|
|||
if (!form) { // Cannot do client-side validation without a form
|
|||
return; |
|||
} |
|||
|
|||
valInfo = validationInfo(form); |
|||
valInfo.options.rules[element.name] = rules = {}; |
|||
valInfo.options.messages[element.name] = messages = {}; |
|||
|
|||
$.each(this.adapters, function () { |
|||
var prefix = "data-val-" + this.name, |
|||
message = $element.attr(prefix), |
|||
paramValues = {}; |
|||
|
|||
if (message !== undefined) { // Compare against undefined, because an empty message is legal (and falsy)
|
|||
prefix += "-"; |
|||
|
|||
$.each(this.params, function () { |
|||
paramValues[this] = $element.attr(prefix + this); |
|||
}); |
|||
|
|||
this.adapt({ |
|||
element: element, |
|||
form: form, |
|||
message: message, |
|||
params: paramValues, |
|||
rules: rules, |
|||
messages: messages |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
$.extend(rules, { "__dummy__": true }); |
|||
|
|||
if (!skipAttach) { |
|||
valInfo.attachValidation(); |
|||
} |
|||
}, |
|||
|
|||
parse: function (selector) { |
|||
/// <summary>
|
|||
/// Parses all the HTML elements in the specified selector. It looks for input elements decorated
|
|||
/// with the [data-val=true] attribute value and enables validation according to the data-val-*
|
|||
/// attribute values.
|
|||
/// </summary>
|
|||
/// <param name="selector" type="String">Any valid jQuery selector.</param>
|
|||
|
|||
// $forms includes all forms in selector's DOM hierarchy (parent, children and self) that have at least one
|
|||
// element with data-val=true
|
|||
var $selector = $(selector), |
|||
$forms = $selector.parents() |
|||
.addBack() |
|||
.filter("form") |
|||
.add($selector.find("form")) |
|||
.has("[data-val=true]"); |
|||
|
|||
$selector.find("[data-val=true]").each(function () { |
|||
$jQval.unobtrusive.parseElement(this, true); |
|||
}); |
|||
|
|||
$forms.each(function () { |
|||
var info = validationInfo(this); |
|||
if (info) { |
|||
info.attachValidation(); |
|||
} |
|||
}); |
|||
} |
|||
}; |
|||
|
|||
adapters = $jQval.unobtrusive.adapters; |
|||
|
|||
adapters.add = function (adapterName, params, fn) { |
|||
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation.</summary>
|
|||
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|||
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
|
|||
/// <param name="params" type="Array" optional="true">[Optional] An array of parameter names (strings) that will
|
|||
/// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and
|
|||
/// mmmm is the parameter name).</param>
|
|||
/// <param name="fn" type="Function">The function to call, which adapts the values from the HTML
|
|||
/// attributes into jQuery Validate rules and/or messages.</param>
|
|||
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|||
if (!fn) { // Called with no params, just a function
|
|||
fn = params; |
|||
params = []; |
|||
} |
|||
this.push({ name: adapterName, params: params, adapt: fn }); |
|||
return this; |
|||
}; |
|||
|
|||
adapters.addBool = function (adapterName, ruleName) { |
|||
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
|
|||
/// the jQuery Validate validation rule has no parameter values.</summary>
|
|||
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|||
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
|
|||
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
|
|||
/// of adapterName will be used instead.</param>
|
|||
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|||
return this.add(adapterName, function (options) { |
|||
setValidationValues(options, ruleName || adapterName, true); |
|||
}); |
|||
}; |
|||
|
|||
adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) { |
|||
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
|
|||
/// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and
|
|||
/// one for min-and-max). The HTML parameters are expected to be named -min and -max.</summary>
|
|||
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|||
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
|
|||
/// <param name="minRuleName" type="String">The name of the jQuery Validate rule to be used when you only
|
|||
/// have a minimum value.</param>
|
|||
/// <param name="maxRuleName" type="String">The name of the jQuery Validate rule to be used when you only
|
|||
/// have a maximum value.</param>
|
|||
/// <param name="minMaxRuleName" type="String">The name of the jQuery Validate rule to be used when you
|
|||
/// have both a minimum and maximum value.</param>
|
|||
/// <param name="minAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
|
|||
/// contains the minimum value. The default is "min".</param>
|
|||
/// <param name="maxAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
|
|||
/// contains the maximum value. The default is "max".</param>
|
|||
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|||
return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) { |
|||
var min = options.params.min, |
|||
max = options.params.max; |
|||
|
|||
if (min && max) { |
|||
setValidationValues(options, minMaxRuleName, [min, max]); |
|||
} |
|||
else if (min) { |
|||
setValidationValues(options, minRuleName, min); |
|||
} |
|||
else if (max) { |
|||
setValidationValues(options, maxRuleName, max); |
|||
} |
|||
}); |
|||
}; |
|||
|
|||
adapters.addSingleVal = function (adapterName, attribute, ruleName) { |
|||
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
|
|||
/// the jQuery Validate validation rule has a single value.</summary>
|
|||
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|||
/// in the data-val-nnnn HTML attribute(where nnnn is the adapter name).</param>
|
|||
/// <param name="attribute" type="String">[Optional] The name of the HTML attribute that contains the value.
|
|||
/// The default is "val".</param>
|
|||
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
|
|||
/// of adapterName will be used instead.</param>
|
|||
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|||
return this.add(adapterName, [attribute || "val"], function (options) { |
|||
setValidationValues(options, ruleName || adapterName, options.params[attribute]); |
|||
}); |
|||
}; |
|||
|
|||
$jQval.addMethod("__dummy__", function (value, element, params) { |
|||
return true; |
|||
}); |
|||
|
|||
$jQval.addMethod("regex", function (value, element, params) { |
|||
var match; |
|||
if (this.optional(element)) { |
|||
return true; |
|||
} |
|||
|
|||
match = new RegExp(params).exec(value); |
|||
return (match && (match.index === 0) && (match[0].length === value.length)); |
|||
}); |
|||
|
|||
$jQval.addMethod("nonalphamin", function (value, element, nonalphamin) { |
|||
var match; |
|||
if (nonalphamin) { |
|||
match = value.match(/\W/g); |
|||
match = match && match.length >= nonalphamin; |
|||
} |
|||
return match; |
|||
}); |
|||
|
|||
if ($jQval.methods.extension) { |
|||
adapters.addSingleVal("accept", "mimtype"); |
|||
adapters.addSingleVal("extension", "extension"); |
|||
} else { |
|||
// for backward compatibility, when the 'extension' validation method does not exist, such as with versions
|
|||
// of JQuery Validation plugin prior to 1.10, we should use the 'accept' method for
|
|||
// validating the extension, and ignore mime-type validations as they are not supported.
|
|||
adapters.addSingleVal("extension", "extension", "accept"); |
|||
} |
|||
|
|||
adapters.addSingleVal("regex", "pattern"); |
|||
adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"); |
|||
adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range"); |
|||
adapters.addMinMax("minlength", "minlength").addMinMax("maxlength", "minlength", "maxlength"); |
|||
adapters.add("equalto", ["other"], function (options) { |
|||
var prefix = getModelPrefix(options.element.name), |
|||
other = options.params.other, |
|||
fullOtherName = appendModelPrefix(other, prefix), |
|||
element = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(fullOtherName) + "']")[0]; |
|||
|
|||
setValidationValues(options, "equalTo", element); |
|||
}); |
|||
adapters.add("required", function (options) { |
|||
// jQuery Validate equates "required" with "mandatory" for checkbox elements
|
|||
if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") { |
|||
setValidationValues(options, "required", true); |
|||
} |
|||
}); |
|||
adapters.add("remote", ["url", "type", "additionalfields"], function (options) { |
|||
var value = { |
|||
url: options.params.url, |
|||
type: options.params.type || "GET", |
|||
data: {} |
|||
}, |
|||
prefix = getModelPrefix(options.element.name); |
|||
|
|||
$.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) { |
|||
var paramName = appendModelPrefix(fieldName, prefix); |
|||
value.data[paramName] = function () { |
|||
var field = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(paramName) + "']"); |
|||
// For checkboxes and radio buttons, only pick up values from checked fields.
|
|||
if (field.is(":checkbox")) { |
|||
return field.filter(":checked").val() || field.filter(":hidden").val() || ''; |
|||
} |
|||
else if (field.is(":radio")) { |
|||
return field.filter(":checked").val() || ''; |
|||
} |
|||
return field.val(); |
|||
}; |
|||
}); |
|||
|
|||
setValidationValues(options, "remote", value); |
|||
}); |
|||
adapters.add("password", ["min", "nonalphamin", "regex"], function (options) { |
|||
if (options.params.min) { |
|||
setValidationValues(options, "minlength", options.params.min); |
|||
} |
|||
if (options.params.nonalphamin) { |
|||
setValidationValues(options, "nonalphamin", options.params.nonalphamin); |
|||
} |
|||
if (options.params.regex) { |
|||
setValidationValues(options, "regex", options.params.regex); |
|||
} |
|||
}); |
|||
adapters.add("fileextensions", ["extensions"], function (options) { |
|||
setValidationValues(options, "extension", options.params.extensions); |
|||
}); |
|||
|
|||
$(function () { |
|||
$jQval.unobtrusive.parse(document); |
|||
}); |
|||
|
|||
return $jQval.unobtrusive; |
|||
})); |
|||
File diff suppressed because one or more lines are too long
@ -1,22 +0,0 @@ |
|||
The MIT License (MIT) |
|||
===================== |
|||
|
|||
Copyright Jörn Zaefferer |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in |
|||
all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|||
THE SOFTWARE. |
|||
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
@ -1,36 +0,0 @@ |
|||
Copyright JS Foundation and other contributors, https://js.foundation/ |
|||
|
|||
This software consists of voluntary contributions made by many |
|||
individuals. For exact contribution history, see the revision history |
|||
available at https://github.com/jquery/jquery |
|||
|
|||
The following license applies to all parts of this software except as |
|||
documented below: |
|||
|
|||
==== |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining |
|||
a copy of this software and associated documentation files (the |
|||
"Software"), to deal in the Software without restriction, including |
|||
without limitation the rights to use, copy, modify, merge, publish, |
|||
distribute, sublicense, and/or sell copies of the Software, and to |
|||
permit persons to whom the Software is furnished to do so, subject to |
|||
the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be |
|||
included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
|||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
|||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|||
|
|||
==== |
|||
|
|||
All files located in the node_modules and external directories are |
|||
externally maintained libraries used by this software which have their |
|||
own licenses; we recommend you read them, as their terms may differ from |
|||
the terms above. |
|||
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,19 @@ |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Sms; |
|||
|
|||
namespace LINGYUN.Abp.Notifications.Sms |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpNotificationModule), |
|||
typeof(AbpSmsModule))] |
|||
public class AbpNotificationsSmsModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpNotificationOptions>(options => |
|||
{ |
|||
options.PublishProviders.Add<SmsNotificationPublishProvider>(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Sms" Version="3.3.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Notifications\LINGYUN.Abp.Notifications.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Notifications.Sms |
|||
{ |
|||
public interface IUserPhoneFinder |
|||
{ |
|||
Task<IEnumerable<string>> FindByUserIdsAsync( |
|||
IEnumerable<Guid> userIds, |
|||
CancellationToken cancellation = default); |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
namespace LINGYUN.Abp.Notifications.Sms |
|||
{ |
|||
public class NotificationSmsOptions |
|||
{ |
|||
/// <summary>
|
|||
/// 短信模板变量前缀
|
|||
/// </summary>
|
|||
public string TemplateParamsPrefix { get; set; } = "[sms]"; |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace LINGYUN.Abp.Notifications.Sms |
|||
{ |
|||
public class NullUserPhoneFinder : IUserPhoneFinder, ISingletonDependency |
|||
{ |
|||
public Task<IEnumerable<string>> FindByUserIdsAsync(IEnumerable<Guid> userIds, CancellationToken cancellation = default) |
|||
{ |
|||
IEnumerable<string> emptyPhoneList = new string[0]; |
|||
|
|||
return Task.FromResult(emptyPhoneList); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Sms; |
|||
|
|||
namespace LINGYUN.Abp.Notifications.Sms |
|||
{ |
|||
public class SmsNotificationPublishProvider : NotificationPublishProvider |
|||
{ |
|||
private IUserPhoneFinder _userPhoneFinder; |
|||
protected IUserPhoneFinder UserPhoneFinder => LazyGetRequiredService(ref _userPhoneFinder); |
|||
|
|||
private ISmsSender _smsSender; |
|||
protected ISmsSender SmsSender => LazyGetRequiredService(ref _smsSender); |
|||
|
|||
protected NotificationSmsOptions Options { get; } |
|||
|
|||
public SmsNotificationPublishProvider( |
|||
IServiceProvider serviceProvider, |
|||
IOptions<NotificationSmsOptions> options) |
|||
: base(serviceProvider) |
|||
{ |
|||
Options = options.Value; |
|||
} |
|||
|
|||
public override string Name => "Sms"; |
|||
|
|||
protected override async Task PublishAsync( |
|||
NotificationInfo notification, |
|||
IEnumerable<UserIdentifier> identifiers, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
if (!identifiers.Any()) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var templateCode = notification.Data.TryGetData("TemplateCode"); |
|||
if (templateCode == null) |
|||
{ |
|||
Logger.LogWarning("sms template code is empty, can not send sms message!"); |
|||
return; |
|||
} |
|||
|
|||
var sendToPhones = await UserPhoneFinder.FindByUserIdsAsync(identifiers.Select(usr => usr.UserId), cancellationToken); |
|||
if (!sendToPhones.Any()) |
|||
{ |
|||
return; |
|||
} |
|||
var message = new SmsMessage(sendToPhones.JoinAsString(","), "SmsNotification"); |
|||
|
|||
// TODO: 后期增强功能,增加短信模板、通知模板功能
|
|||
message.Properties.Add("TemplateCode", templateCode); |
|||
message.Properties.Add("SignName", notification.Data.TryGetData("SignName")); |
|||
|
|||
foreach (var property in notification.Data.Properties) |
|||
{ |
|||
// TODO: 可以扩展下存储短信模板,根据模板变量自动匹配
|
|||
// 必须加上需要发送短信的前缀让用户自己选择是否发送短信,因为资费太贵了...
|
|||
if (property.Key.StartsWith(Options.TemplateParamsPrefix)) |
|||
{ |
|||
message.Properties.Add(property.Key.Replace(Options.TemplateParamsPrefix, ""), property.Value); |
|||
} |
|||
} |
|||
|
|||
await SmsSender.SendAsync(message); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,107 @@ |
|||
using AuthServer.Host.Emailing.Templates; |
|||
using LINGYUN.Abp.Account; |
|||
using Microsoft.Extensions.Localization; |
|||
using System; |
|||
using System.Diagnostics; |
|||
using System.Text.Encodings.Web; |
|||
using System.Threading.Tasks; |
|||
using System.Web; |
|||
using Volo.Abp.Account.Emailing; |
|||
using Volo.Abp.Account.Localization; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Emailing; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.TextTemplating; |
|||
using Volo.Abp.UI.Navigation.Urls; |
|||
|
|||
namespace AuthServer.Host.Emailing |
|||
{ |
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices( |
|||
typeof(IAccountEmailer), |
|||
typeof(AccountEmailer), |
|||
typeof(IAccountEmailVerifySender), |
|||
typeof(AccountEmailVerifySender))] |
|||
public class AccountEmailVerifySender : AccountEmailer, IAccountEmailVerifySender, ITransientDependency |
|||
{ |
|||
public AccountEmailVerifySender( |
|||
IEmailSender emailSender, |
|||
ITemplateRenderer templateRenderer, |
|||
IStringLocalizer<AccountResource> stringLocalizer, |
|||
IAppUrlProvider appUrlProvider, |
|||
ICurrentTenant currentTenant) |
|||
: base(emailSender, templateRenderer, stringLocalizer, appUrlProvider, currentTenant) |
|||
{ |
|||
} |
|||
|
|||
public virtual async Task SendMailLoginVerifyLinkAsync( |
|||
IdentityUser user, |
|||
string code, |
|||
string appName, |
|||
string provider, |
|||
bool rememberMe = false, |
|||
string returnUrl = null, |
|||
string returnUrlHash = null) |
|||
{ |
|||
Debug.Assert(CurrentTenant.Id == user.TenantId, "This method can only work for current tenant!"); |
|||
|
|||
// TODO: 需要生成快捷链接
|
|||
//var url = await AppUrlProvider.GetUrlAsync(appName, AccountUrlNames.MailLoginVerify);
|
|||
|
|||
//var link = $"{url}?provider={provider}&rememberMe={rememberMe}&resetToken={UrlEncoder.Default.Encode(code)}";
|
|||
|
|||
//if (!returnUrl.IsNullOrEmpty())
|
|||
//{
|
|||
// link += "&returnUrl=" + NormalizeReturnUrl(returnUrl);
|
|||
//}
|
|||
|
|||
//if (!returnUrlHash.IsNullOrEmpty())
|
|||
//{
|
|||
// link += "&returnUrlHash=" + returnUrlHash;
|
|||
//}
|
|||
|
|||
var emailContent = await TemplateRenderer.RenderAsync( |
|||
AccountEmailTemplates.MailSecurityVerifyLink, |
|||
new { code = code, user = user.UserName } |
|||
); |
|||
|
|||
await EmailSender.SendAsync( |
|||
user.Email, |
|||
StringLocalizer["MailSecurityVerify"], |
|||
emailContent |
|||
); |
|||
} |
|||
|
|||
private string NormalizeReturnUrl(string returnUrl) |
|||
{ |
|||
if (returnUrl.IsNullOrEmpty()) |
|||
{ |
|||
return returnUrl; |
|||
} |
|||
|
|||
//Handling openid connect login
|
|||
if (returnUrl.StartsWith("/connect/authorize/callback", StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
if (returnUrl.Contains("?")) |
|||
{ |
|||
var queryPart = returnUrl.Split('?')[1]; |
|||
var queryParameters = queryPart.Split('&'); |
|||
foreach (var queryParameter in queryParameters) |
|||
{ |
|||
if (queryParameter.Contains("=")) |
|||
{ |
|||
var queryParam = queryParameter.Split('='); |
|||
if (queryParam[0] == "redirect_uri") |
|||
{ |
|||
return HttpUtility.UrlDecode(queryParam[1]); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
return returnUrl; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Account.Emailing; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace AuthServer.Host.Emailing |
|||
{ |
|||
public interface IAccountEmailVerifySender : IAccountEmailer |
|||
{ |
|||
Task SendMailLoginVerifyLinkAsync( |
|||
IdentityUser user, |
|||
string code, |
|||
string appName, |
|||
string provider, |
|||
bool rememberMe = false, |
|||
string returnUrl = null, |
|||
string returnUrlHash = null); |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using Volo.Abp.Account.Localization; |
|||
using Volo.Abp.Emailing.Templates; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace AuthServer.Host.Emailing.Templates |
|||
{ |
|||
public class AccountEmailTemplateDefinitionProvider : TemplateDefinitionProvider |
|||
{ |
|||
public override void Define(ITemplateDefinitionContext context) |
|||
{ |
|||
context.Add( |
|||
new TemplateDefinition( |
|||
AccountEmailTemplates.MailSecurityVerifyLink, |
|||
displayName: LocalizableString.Create<AccountResource>($"TextTemplate:{AccountEmailTemplates.MailSecurityVerifyLink}"), |
|||
layout: StandardEmailTemplates.Layout, |
|||
localizationResource: typeof(AccountResource) |
|||
).WithVirtualFilePath("/Emailing/Templates/MailSecurityVerify.tpl", true) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
namespace AuthServer.Host.Emailing.Templates |
|||
{ |
|||
public static class AccountEmailTemplates |
|||
{ |
|||
/// <summary>
|
|||
/// 邮件安全验证
|
|||
/// </summary>
|
|||
public const string MailSecurityVerifyLink = "Abp.Account.MailSecurityVerifyLink"; |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
<div style="position: absolute;"> |
|||
<span>{{L "VerifyMyEmailAddress" model.user}}</span> |
|||
<p style="display:block; padding:0 50px; width: 150px; height:48px; line-height:48px; color:#cc0000; font-size:26px; background:#9c9797; font-weight:bold;">{{model.code}}</p> |
|||
<span>{{L "MailSecurityVerifyRemarks"}}</span> |
|||
</div> |
|||
@ -0,0 +1,18 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
"TwoFactor": "Two factor authentication", |
|||
"SelectedProvider": "Select validation mode", |
|||
"SendVerifyCode": "Send verification code", |
|||
"VerifyCode": "Verification code", |
|||
"VerifyAuthenticatorCode": "Authentication code", |
|||
"RememberBrowser": "Remember me in the browser", |
|||
"TwoFactorAuthenticationInvaidUser": "Authentication failed. Your session is invalid. Please re login try again!", |
|||
"InvaidGenerateTwoFactorToken": "Verification code generation failed. Please contact your administrator!", |
|||
"TextTemplate:Abp.Account.MailSecurityVerifyLink": "Mail security validation template", |
|||
"MailSecurityVerify": "Mail security verification", |
|||
"VerifyMyEmailAddress": "Hello {0}<br/><p>Your email security verification code is as follows. Please enter the verification code to proceed to the next step.</p><p>If not operated by you, please ignore this email.</p>", |
|||
"MailSecurityVerifyRemarks": "<p>(If it is not in the form of a link, copy the address to the browser address bar for further access)</p><p>Thank you for your visit and have a good time!</p>", |
|||
"ClickToValidation": "Click link verification" |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
{ |
|||
"culture": "zh-Hans", |
|||
"texts": { |
|||
"TwoFactor": "双因素身份验证", |
|||
"SelectedProvider": "选择验证方式", |
|||
"SendVerifyCode": "发送验证码", |
|||
"VerifyCode": "验证码", |
|||
"VerifyAuthenticatorCode": "验证身份代码", |
|||
"RememberBrowser": "在浏览器中记住我", |
|||
"TwoFactorAuthenticationInvaidUser": "认证失败,您的会话已失效,请程序登录!", |
|||
"InvaidGenerateTwoFactorToken": "验证码生成失败,请联系管理员!", |
|||
"TextTemplate:Abp.Account.MailSecurityVerifyLink": "邮件安全验证模板", |
|||
"MailSecurityVerify": "邮件安全验证", |
|||
"VerifyMyEmailAddress": "亲爱的 {0},您好<br/><p>您此次邮件安全验证码如下,请输入验证码进行下一步操作。</p><p>如非你本人操作,请忽略此邮件。</p>", |
|||
"MailSecurityVerifyRemarks": "此邮件为系统所发,请勿直接回复。", |
|||
"ClickToValidation": "点击进行验证" |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
@page |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.Account.Localization |
|||
@model LINGYUN.Abp.Account.Web.Pages.Account.SendCodeModel |
|||
@inject IHtmlLocalizer<AccountResource> L |
|||
|
|||
<div class="card mt-3 shadow-sm rounded"> |
|||
<div class="card-body p-5"> |
|||
<h4>@L["TwoFactor"]</h4> |
|||
<form method="post" class="mt-4"> |
|||
<abp-input asp-for="RememberMe" /> |
|||
<input asp-for="ReturnUrl" /> |
|||
<input asp-for="ReturnUrlHash" /> |
|||
<div class="form-group"> |
|||
<abp-select asp-for="SendCodeInput.SelectedProvider" label="@L["SelectedProvider"].Value" asp-items="@Model.Providers"></abp-select> |
|||
</div> |
|||
<abp-button type="submit" button-type="Primary" class="btn-block btn-lg mt-3">@L["SendVerifyCode"]</abp-button> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
|
|||
@ -0,0 +1,128 @@ |
|||
using AuthServer.Host.Emailing; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.Rendering; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Account.Localization; |
|||
using Volo.Abp.Account.Web.Pages.Account; |
|||
using Volo.Abp.Sms; |
|||
|
|||
namespace LINGYUN.Abp.Account.Web.Pages.Account |
|||
{ |
|||
public class SendCodeModel : AccountPageModel |
|||
{ |
|||
[BindProperty] |
|||
public SendCodeInputModel SendCodeInput { get; set; } |
|||
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public string ReturnUrl { get; set; } |
|||
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public string ReturnUrlHash { get; set; } |
|||
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public bool RememberMe { get; set; } |
|||
|
|||
public IEnumerable<SelectListItem> Providers { get; set; } |
|||
|
|||
protected ISmsSender SmsSender { get; } |
|||
|
|||
protected IAccountEmailVerifySender AccountEmailVerifySender { get; } |
|||
|
|||
public SendCodeModel( |
|||
ISmsSender smsSender, |
|||
IAccountEmailVerifySender accountEmailVerifySender) |
|||
{ |
|||
SmsSender = smsSender; |
|||
AccountEmailVerifySender = accountEmailVerifySender; |
|||
|
|||
LocalizationResourceType = typeof(AccountResource); |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnGetAsync() |
|||
{ |
|||
SendCodeInput = new SendCodeInputModel(); |
|||
|
|||
var user = await SignInManager.GetTwoFactorAuthenticationUserAsync(); |
|||
if (user == null) |
|||
{ |
|||
// 双因素信息验证失败,一般都是超时了或者用户信息变更
|
|||
Alerts.Warning(L["TwoFactorAuthenticationInvaidUser"]); |
|||
return Page(); |
|||
} |
|||
var userFactors = await UserManager.GetValidTwoFactorProvidersAsync(user); |
|||
Providers = userFactors.Select(purpose => new SelectListItem { Text = purpose, Value = purpose }).ToList(); |
|||
|
|||
return Page(); |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var user = await SignInManager.GetTwoFactorAuthenticationUserAsync(); |
|||
if (user == null) |
|||
{ |
|||
Alerts.Warning(L["TwoFactorAuthenticationInvaidUser"]); |
|||
return Page(); |
|||
} |
|||
|
|||
if (SendCodeInput.SelectedProvider == "Authenticator") |
|||
{ |
|||
// 用户通过邮件/短信链接进入授权页面
|
|||
return RedirectToPage("VerifyAuthenticatorCode", new |
|||
{ |
|||
returnUrl = ReturnUrl, |
|||
returnUrlHash = ReturnUrlHash, |
|||
rememberMe = RememberMe |
|||
}); |
|||
} |
|||
// 生成验证码
|
|||
var code = await UserManager.GenerateTwoFactorTokenAsync(user, SendCodeInput.SelectedProvider); |
|||
if (string.IsNullOrWhiteSpace(code)) |
|||
{ |
|||
Alerts.Warning(L["InvaidGenerateTwoFactorToken"]); |
|||
return Page(); |
|||
} |
|||
|
|||
if (SendCodeInput.SelectedProvider == "Email") |
|||
{ |
|||
var appName = "MVC"; // TODO: 跟随Abp框架的意思变动
|
|||
await AccountEmailVerifySender |
|||
.SendMailLoginVerifyLinkAsync( |
|||
user, code, appName, |
|||
SendCodeInput.SelectedProvider, |
|||
RememberMe, ReturnUrl, ReturnUrlHash); |
|||
} |
|||
else if (SendCodeInput.SelectedProvider == "Phone") |
|||
{ |
|||
var phoneNumber = await UserManager.GetPhoneNumberAsync(user); |
|||
var templateCode = await SettingProvider.GetOrNullAsync(AccountSettingNames.SmsSigninTemplateCode); |
|||
Check.NotNullOrWhiteSpace(templateCode, nameof(AccountSettingNames.SmsSigninTemplateCode)); |
|||
|
|||
// TODO: 以后扩展短信模板发送
|
|||
var smsMessage = new SmsMessage(phoneNumber, code); |
|||
smsMessage.Properties.Add("code", code); |
|||
smsMessage.Properties.Add("TemplateCode", templateCode); |
|||
|
|||
await SmsSender.SendAsync(smsMessage); |
|||
} |
|||
|
|||
return RedirectToPage("VerifyCode", new |
|||
{ |
|||
provider = SendCodeInput.SelectedProvider, |
|||
returnUrl = ReturnUrl, |
|||
returnUrlHash = ReturnUrlHash, |
|||
rememberMe = RememberMe |
|||
}); |
|||
} |
|||
} |
|||
|
|||
public class SendCodeInputModel |
|||
{ |
|||
public string SelectedProvider { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using IdentityServer4.Services; |
|||
using IdentityServer4.Stores; |
|||
using Microsoft.AspNetCore.Authentication; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Options; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Account.Web; |
|||
using Volo.Abp.Account.Web.Pages.Account; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace AuthServer.Host.Pages.Account |
|||
{ |
|||
/// <summary>
|
|||
/// 重写登录模型,实现双因素登录
|
|||
/// </summary>
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(LoginModel), typeof(IdentityServerSupportedLoginModel))] |
|||
public class TwoFactorSupportedLoginModel : IdentityServerSupportedLoginModel |
|||
{ |
|||
public TwoFactorSupportedLoginModel( |
|||
IAuthenticationSchemeProvider schemeProvider, |
|||
IOptions<AbpAccountOptions> accountOptions, |
|||
IIdentityServerInteractionService interaction, |
|||
IClientStore clientStore, |
|||
IEventService identityServerEvents) |
|||
: base(schemeProvider, accountOptions, interaction, clientStore, identityServerEvents) |
|||
{ |
|||
|
|||
} |
|||
|
|||
protected override Task<IActionResult> TwoFactorLoginResultAsync() |
|||
{ |
|||
// 重定向双因素认证页面
|
|||
return Task.FromResult<IActionResult>(RedirectToPage("SendCode", new |
|||
{ |
|||
returnUrl = ReturnUrl, |
|||
returnUrlHash = ReturnUrlHash, |
|||
rememberMe = LoginInput.RememberMe |
|||
})); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
@page |
|||
@model LINGYUN.Abp.Account.Web.Pages.Account.UseRecoveryCodeModel |
|||
@{ |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
|
|||
namespace LINGYUN.Abp.Account.Web.Pages.Account |
|||
{ |
|||
public class UseRecoveryCodeModel : PageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
@page |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.Account.Localization |
|||
@model LINGYUN.Abp.Account.Web.Pages.Account.VerifyAuthenticatorCodeModel |
|||
@inject IHtmlLocalizer<AccountResource> L |
|||
<div class="card mt-3 shadow-sm rounded"> |
|||
<div class="card-body p-5"> |
|||
<form method="post" class="mt-4"> |
|||
<input asp-for="RememberMe" /> |
|||
<input asp-for="ReturnUrlHash" /> |
|||
<div class="form-group"> |
|||
<label asp-for="Input.VerifyCode"></label> |
|||
<input asp-for="Input.VerifyCode" class="form-control" /> |
|||
<span asp-validation-for="Input.VerifyCode" class="text-danger"></span> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label asp-for="RememberBrowser"></label> |
|||
<abp-input asp-for="RememberBrowser" /> |
|||
</div> |
|||
<abp-button type="submit" button-type="Primary" class="btn-block btn-lg mt-3">@L["VerifyAuthenticatorCode"]</abp-button> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,61 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Account.Web.Pages.Account; |
|||
|
|||
namespace LINGYUN.Abp.Account.Web.Pages.Account |
|||
{ |
|||
public class VerifyAuthenticatorCodeModel : AccountPageModel |
|||
{ |
|||
[BindProperty] |
|||
public VerifyAuthenticatorCodeInputModel Input { get; set; } |
|||
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public string ReturnUrl { get; set; } |
|||
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public string ReturnUrlHash { get; set; } |
|||
|
|||
[BindProperty(SupportsGet = true)] |
|||
public bool RememberBrowser { get; set; } |
|||
|
|||
[HiddenInput] |
|||
public bool RememberMe { get; set; } |
|||
|
|||
public virtual IActionResult OnGet() |
|||
{ |
|||
Input = new VerifyAuthenticatorCodeInputModel(); |
|||
|
|||
return Page(); |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var result = await SignInManager.TwoFactorAuthenticatorSignInAsync(Input.VerifyCode, RememberMe, RememberBrowser); |
|||
if (result.Succeeded) |
|||
{ |
|||
return RedirectSafely(ReturnUrl, ReturnUrlHash); |
|||
} |
|||
if (result.IsLockedOut) |
|||
{ |
|||
Logger.LogWarning(7, "User account locked out."); |
|||
Alerts.Warning(L["UserLockedOutMessage"]); |
|||
return Page(); |
|||
} |
|||
else |
|||
{ |
|||
Alerts.Danger(L["TwoFactorAuthenticationInvaidUser"]);// TODO: ¸ü¶à״̬ÂëµÄ½â¶Á
|
|||
return Page(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class VerifyAuthenticatorCodeInputModel |
|||
{ |
|||
[Required] |
|||
public string VerifyCode { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
@page |
|||
@inject IHtmlLocalizer<AccountResource> L |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.Account.Localization |
|||
@model LINGYUN.Abp.Account.Web.Pages.Account.VerifyCodeModel |
|||
<div class="card mt-3 shadow-sm rounded"> |
|||
<div class="card-body p-5"> |
|||
<form method="post" class="mt-4"> |
|||
<input asp-for="Provider" /> |
|||
<input asp-for="ReturnUrl" /> |
|||
<input asp-for="ReturnUrlHash" /> |
|||
<input asp-for="RememberMe" /> |
|||
<div class="form-group"> |
|||
<abp-input asp-for="Input.VerifyCode" label="@L["VerifyCode"].Value" class="form-control" /> |
|||
</div> |
|||
<abp-row> |
|||
<abp-column> |
|||
<abp-input asp-for="Input.RememberBrowser" label="@L["RememberBrowser"].Value" /> |
|||
</abp-column> |
|||
</abp-row> |
|||
<abp-button type="submit" button-type="Primary" class="btn-block btn-lg mt-3">@L["VerifyAuthenticatorCode"]</abp-button> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,92 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Account.Localization; |
|||
using Volo.Abp.Account.Web.Pages.Account; |
|||
|
|||
namespace LINGYUN.Abp.Account.Web.Pages.Account |
|||
{ |
|||
public class VerifyCodeModel : AccountPageModel |
|||
{ |
|||
[BindProperty] |
|||
public VerifyCodeInputModel Input { get; set; } |
|||
/// <summary>
|
|||
/// 双因素认证提供程序
|
|||
/// </summary>
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public string Provider { get; set; } |
|||
/// <summary>
|
|||
/// 重定向Url
|
|||
/// </summary>
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public string ReturnUrl { get; set; } |
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public string ReturnUrlHash { get; set; } |
|||
/// <summary>
|
|||
/// 是否记住登录状态
|
|||
/// </summary>
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public bool RememberMe { get; set; } |
|||
|
|||
public VerifyCodeModel() |
|||
{ |
|||
LocalizationResourceType = typeof(AccountResource); |
|||
} |
|||
|
|||
public virtual IActionResult OnGet() |
|||
{ |
|||
Input = new VerifyCodeInputModel(); |
|||
|
|||
return Page(); |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
// 验证用户登录状态
|
|||
var user = await SignInManager.GetTwoFactorAuthenticationUserAsync(); |
|||
if (user == null) |
|||
{ |
|||
Alerts.Warning(L["TwoFactorAuthenticationInvaidUser"]); |
|||
return Page(); |
|||
} |
|||
// 双因素登录
|
|||
var result = await SignInManager.TwoFactorSignInAsync(Provider, Input.VerifyCode, RememberMe, Input.RememberBrowser); |
|||
if (result.Succeeded) |
|||
{ |
|||
return RedirectSafely(ReturnUrl, ReturnUrlHash); |
|||
} |
|||
if (result.IsLockedOut) |
|||
{ |
|||
Logger.LogWarning(7, "User account locked out."); |
|||
Alerts.Warning(L["UserLockedOutMessage"]); |
|||
return Page(); |
|||
} |
|||
else |
|||
{ |
|||
Alerts.Danger(L["TwoFactorAuthenticationInvaidUser"]);// TODO: 更多状态码的解读
|
|||
return Page(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class VerifyCodeInputModel |
|||
{ |
|||
/// <summary>
|
|||
/// 是否在浏览器中记住登录状态
|
|||
/// </summary>
|
|||
public bool RememberBrowser { get; set; } |
|||
/// <summary>
|
|||
/// 发送的验证码
|
|||
/// </summary>
|
|||
[Required] |
|||
public string VerifyCode { get; set; } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue