mirror of https://github.com/abpframework/abp
				
				
				
			
							parent
							
								
									478e93f9c3
								
							
						
					
					
						commit
						8614a45c8f
					
				| @ -0,0 +1,21 @@ | ||||
| @page | ||||
| @inject IHtmlLocalizer<AccountResource> L | ||||
| @using Microsoft.AspNetCore.Mvc.Localization | ||||
| @using Volo.Abp.Account.Localization | ||||
| @model Volo.Abp.Account.Web.Pages.Account.ForgotPasswordModel | ||||
| @inject Volo.Abp.AspNetCore.Mvc.UI.Layout.IPageLayout PageLayout | ||||
| @{ | ||||
|     PageLayout.Content.Title = L["ForgotPassword"].Value; | ||||
| } | ||||
| <div class="account-module-form"> | ||||
|     <form method="post"> | ||||
|         <p>@L["SendPasswordResetLink_Information"]</p> | ||||
|         <input asp-for="ReturnUrl"/> | ||||
|         <input asp-for="ReturnUrlHash"/> | ||||
|         <abp-input asp-for="Email"/> | ||||
|         <abp-button button-type="Primary" size="Block" type="submit" class="mt-2 mb-3">@L["Submit"]</abp-button> | ||||
|         <a asp-page="./Login" asp-all-route-data="@(new Dictionary<string, string>{ {"returnUrl",Model.ReturnUrl}, {"returnUrlHash",Model.ReturnUrlHash} })"> | ||||
|             <i class="fa fa-long-arrow-left"></i> @L["Login"] | ||||
|         </a> | ||||
|     </form> | ||||
| </div> | ||||
| @ -0,0 +1,13 @@ | ||||
| @page | ||||
| @model Volo.Abp.Account.Web.Pages.Account.PasswordResetLinkSentModel | ||||
| @inject Volo.Abp.AspNetCore.Mvc.UI.Layout.IPageLayout PageLayout | ||||
| @using Microsoft.AspNetCore.Mvc.Localization | ||||
| @using Volo.Abp.Account.Localization | ||||
| @inject IHtmlLocalizer<AccountResource> L | ||||
| @{ | ||||
|     PageLayout.Content.Title = L["ForgotPassword"].Value; | ||||
| } | ||||
| <p>@L["PasswordResetMailSentMessage"]</p> | ||||
| <div class="mt-4"> | ||||
|     <a abp-button="Primary" asp-page="./Login" asp-all-route-data="@(new Dictionary<string, string>{ {"returnUrl",Model.ReturnUrl}, {"returnUrlHash",Model.ReturnUrlHash} })">← @L["BackToLogin"]</a> | ||||
| </div> | ||||
| @ -0,0 +1,24 @@ | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| 
 | ||||
| namespace Volo.Abp.Account.Web.Pages.Account | ||||
| { | ||||
|     public class PasswordResetLinkSentModel : AccountPageModel | ||||
|     { | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public string ReturnUrl { get; set; } | ||||
| 
 | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public string ReturnUrlHash { get; set; } | ||||
| 
 | ||||
|         public virtual Task<IActionResult> OnGetAsync() | ||||
|         { | ||||
|             return Task.FromResult<IActionResult>(Page()); | ||||
|         } | ||||
| 
 | ||||
|         public virtual Task<IActionResult> OnPostAsync() | ||||
|         { | ||||
|             return Task.FromResult<IActionResult>(Page()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,22 @@ | ||||
| @page | ||||
| @inject IHtmlLocalizer<AccountResource> L | ||||
| @using Microsoft.AspNetCore.Mvc.Localization | ||||
| @using Volo.Abp.Account.Localization | ||||
| @model Volo.Abp.Account.Web.Pages.Account.ResetPasswordModel | ||||
| @inject Volo.Abp.AspNetCore.Mvc.UI.Layout.IPageLayout PageLayout | ||||
| @{ | ||||
|     PageLayout.Content.Title = L["ResetPassword"].Value; | ||||
| } | ||||
| <form method="post"> | ||||
|     <p>@L["ResetPassword_Information"]</p> | ||||
| 
 | ||||
|     <abp-input asp-for="ReturnUrl" /> | ||||
|     <abp-input asp-for="ReturnUrlHash" /> | ||||
|     <abp-input asp-for="UserId" /> | ||||
|     <abp-input asp-for="ResetToken" /> | ||||
|     <abp-input asp-for="Password" /> | ||||
|     <abp-input asp-for="ConfirmPassword" /> | ||||
| 
 | ||||
|     <a abp-button="Secondary" asp-page="./Login">@L["Cancel"]</a> | ||||
|     <abp-button type="submit" button-type="Primary" text="@L["Submit"].Value" /> | ||||
| </form> | ||||
| @ -0,0 +1,110 @@ | ||||
| using System; | ||||
| using System.ComponentModel.DataAnnotations; | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Volo.Abp.Auditing; | ||||
| using Volo.Abp.Identity; | ||||
| using Volo.Abp.MultiTenancy; | ||||
| using Volo.Abp.Validation; | ||||
| 
 | ||||
| namespace Volo.Abp.Account.Web.Pages.Account | ||||
| { | ||||
|     //TODO: Implement live password complexity check on the razor view! | ||||
| 
 | ||||
|     public class ResetPasswordModel : AccountPageModel | ||||
|     { | ||||
|         [HiddenInput] | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public Guid? TenantId { get; set; } | ||||
| 
 | ||||
|         [Required] | ||||
|         [HiddenInput] | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public Guid UserId { get; set; } | ||||
| 
 | ||||
|         [Required] | ||||
|         [HiddenInput] | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public string ResetToken { get; set; } | ||||
| 
 | ||||
|         [HiddenInput] | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public string ReturnUrl { get; set; } | ||||
| 
 | ||||
|         [HiddenInput] | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public string ReturnUrlHash { get; set; } | ||||
| 
 | ||||
|         [Required] | ||||
|         [BindProperty] | ||||
|         [DataType(DataType.Password)] | ||||
|         [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] | ||||
|         [DisableAuditing] | ||||
|         public string Password { get; set; } | ||||
| 
 | ||||
|         [Required] | ||||
|         [BindProperty] | ||||
|         [DataType(DataType.Password)] | ||||
|         [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] | ||||
|         [DisableAuditing] | ||||
|         public string ConfirmPassword { get; set; } | ||||
| 
 | ||||
|         protected virtual ITenantResolveResultAccessor TenantResolveResultAccessor { get; } | ||||
| 
 | ||||
|         public ResetPasswordModel(ITenantResolveResultAccessor tenantResolveResultAccessor) | ||||
|         { | ||||
|             TenantResolveResultAccessor = tenantResolveResultAccessor; | ||||
|         } | ||||
| 
 | ||||
|         public virtual Task<IActionResult> OnGetAsync() | ||||
|         { | ||||
|             //TODO: It would be good to try to switch tenant if needed | ||||
|             CheckCurrentTenant(TenantId); | ||||
|             return Task.FromResult<IActionResult>(Page()); | ||||
|         } | ||||
| 
 | ||||
|         public virtual async Task<IActionResult> OnPostAsync() | ||||
|         { | ||||
|             ValidateModel(); | ||||
| 
 | ||||
|             try | ||||
|             { | ||||
|                 await AccountAppService.ResetPasswordAsync( | ||||
|                     new ResetPasswordDto | ||||
|                     { | ||||
|                         UserId = UserId, | ||||
|                         ResetToken = ResetToken, | ||||
|                         Password = Password | ||||
|                     } | ||||
|                 ); | ||||
|             } | ||||
|             catch (AbpIdentityResultException e) | ||||
|             { | ||||
|                 if (!string.IsNullOrWhiteSpace(e.Message)) | ||||
|                 { | ||||
|                     Alerts.Warning(e.Message); | ||||
|                     return Page(); | ||||
|                 } | ||||
| 
 | ||||
|                 throw; | ||||
|             } | ||||
| 
 | ||||
|             //TODO: Try to automatically login! | ||||
|             return RedirectToPage("./ResetPasswordConfirmation", new | ||||
|             { | ||||
|                 returnUrl = ReturnUrl, | ||||
|                 returnUrlHash = ReturnUrlHash | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         protected override void ValidateModel() | ||||
|         { | ||||
|             if (!Equals(Password, ConfirmPassword)) | ||||
|             { | ||||
|                 ModelState.AddModelError("ConfirmPassword", L["'{0}' and '{1}' do not match.", "ConfirmPassword", "Password"]); | ||||
|             } | ||||
| 
 | ||||
|             base.ValidateModel(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,11 @@ | ||||
| @page | ||||
| @model Volo.Abp.Account.Web.Pages.Account.ResetPasswordConfirmationModel | ||||
| @inject Volo.Abp.AspNetCore.Mvc.UI.Layout.IPageLayout PageLayout | ||||
| @using Microsoft.AspNetCore.Mvc.Localization | ||||
| @using Volo.Abp.Account.Localization | ||||
| @inject IHtmlLocalizer<AccountResource> L | ||||
| @{ | ||||
|     PageLayout.Content.Title = L["ResetPassword"].Value; | ||||
| } | ||||
| <p>@L["YourPasswordIsSuccessfullyReset"]</p> | ||||
| <a abp-button="Primary" href="@Url.Content(Model.ReturnUrl)">@L["GoToTheApplication"]</a> | ||||
| @ -0,0 +1,24 @@ | ||||
| using System; | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| 
 | ||||
| namespace Volo.Abp.Account.Web.Pages.Account | ||||
| { | ||||
|     [AllowAnonymous] | ||||
|     public class ResetPasswordConfirmationModel : AccountPageModel | ||||
|     { | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public string ReturnUrl { get; set; } | ||||
| 
 | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public string ReturnUrlHash { get; set; } | ||||
| 
 | ||||
|         public virtual Task<IActionResult> OnGetAsync() | ||||
|         { | ||||
|             ReturnUrl = GetRedirectUrl(ReturnUrl, ReturnUrlHash); | ||||
| 
 | ||||
|             return Task.FromResult<IActionResult>(Page()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue
	
	 liangshiwei
						liangshiwei