Browse Source

Added Locked Out page and NotAllowed logic

pull/9133/head
Galip Tolga Erdem 5 years ago
parent
commit
b33e14bf89
  1. 6
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json
  2. 30
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/LockedOut.cshtml
  3. 18
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/LockedOut.cshtml.cs
  4. 12
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs

6
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.", "PasswordResetInfoInEmail": "We received an account recovery request! If you initiated this request, click the following link to reset your password.",
"ResetMyPassword": "Reset my password", "ResetMyPassword": "Reset my password",
"AccessDenied": "Access denied!", "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."
} }
} }

30
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<AccountResource> 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;
}
<abp-card>
<abp-card-body>
@if (isAccountDisabled)
{
<abp-card-title>@L["AccountDisabledTitle"]</abp-card-title>
<abp-card-text>@L["LoginIsNotAllowed"]</abp-card-text>
}
else
{
<abp-card-title>@L["AccountLockedOutTitle"]</abp-card-title>
<abp-card-text>@L["AccountLockedOutText"]</abp-card-text>
}
</abp-card-body>
</abp-card>

18
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<IActionResult> OnGetAsync()
{
return Task.FromResult<IActionResult>(Page());
}
public virtual Task<IActionResult> OnPostAsync()
{
return Task.FromResult<IActionResult>(Page());
}
}
}

12
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) 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) if (result.Succeeded)

Loading…
Cancel
Save