diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json index 459d115398..0884e04984 100644 --- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json @@ -62,6 +62,10 @@ "PasswordResetInfoInEmail": "We received an account recovery request! If you initiated this request, click the following link to reset your password.", "ResetMyPassword": "Reset my password", "AccessDenied": "Access denied!", - "AccessDeniedMessage": "You do not have access to this resource." + "AccessDeniedMessage": "You do not have access to this resource.", + "LockedOut": "Locked Out", + "AccountDisabledTitle": "Your account is not enabled!", + "AccountLockedOutTitle": "Your account is locked!", + "AccountLockedOutText": "Please contact to admin." } } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LockedOut.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LockedOut.cshtml new file mode 100644 index 0000000000..2fc1083c5b --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LockedOut.cshtml @@ -0,0 +1,30 @@ +@page "/Account/LockedOut" +@model Volo.Abp.Account.Web.Pages.Account.LockedOut +@using Volo.Abp.Account.Localization +@using Microsoft.AspNetCore.Mvc.Localization +@using Volo.Abp.Identity.Settings +@using Volo.Abp.Settings +@inject IHtmlLocalizer L +@inject Volo.Abp.AspNetCore.Mvc.UI.Layout.IPageLayout PageLayout +@inject ISettingProvider SettingProvider +@{ + PageLayout.Content.Title = L["LockedOut"].Value; + var requireConfirmedEmail = await SettingProvider.IsTrueAsync(IdentitySettingNames.SignIn.RequireConfirmedEmail); + var requireConfirmedPhoneNumber = await SettingProvider.IsTrueAsync(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber); + bool isAccountDisabled = requireConfirmedEmail || requireConfirmedPhoneNumber; + +} + + + @if (isAccountDisabled) + { + @L["AccountDisabledTitle"] + @L["LoginIsNotAllowed"] + } + else + { + @L["AccountLockedOutTitle"] + @L["AccountLockedOutText"] + } + + \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LockedOut.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LockedOut.cshtml.cs new file mode 100644 index 0000000000..90eb091d64 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LockedOut.cshtml.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace Volo.Abp.Account.Web.Pages.Account +{ + public class LockedOut : AccountPageModel + { + public virtual Task OnGetAsync() + { + return Task.FromResult(Page()); + } + + public virtual Task OnPostAsync() + { + return Task.FromResult(Page()); + } + } +} \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs index a69b186adc..004df26348 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs @@ -213,7 +213,17 @@ namespace Volo.Abp.Account.Web.Pages.Account if (result.IsLockedOut) { - throw new UserFriendlyException("Cannot proceed because user is locked out!"); + // throw new UserFriendlyException("Cannot proceed because user is locked out!"); + Logger.LogWarning($"Cannot proceed because user is locked out!"); + return RedirectToPage("./LockedOut"); + } + + if (result.IsNotAllowed) + { + // throw new UserFriendlyException("External login callback error: User is Not Allowed!"); + Logger.LogWarning($"External login callback error: User is Not Allowed!"); + // Returns a view informing the user about the locked account + return RedirectToPage("./LockedOut"); } if (result.Succeeded)