Implemented ip ban
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
@inject EventSystem Event
|
||||
@inject ToastService ToastService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject IpBanService IpBanService
|
||||
|
||||
<GlobalErrorBoundary>
|
||||
@{
|
||||
@@ -59,56 +60,72 @@
|
||||
<div id="kt_app_content_container" class="app-container container-fluid">
|
||||
<div class="mt-10">
|
||||
<SoftErrorBoundary>
|
||||
@if (UserProcessed)
|
||||
@if (!IsIpBanned)
|
||||
{
|
||||
@if (uri.LocalPath != "/login" &&
|
||||
uri.LocalPath != "/passwordreset" &&
|
||||
uri.LocalPath != "/register")
|
||||
if (UserProcessed)
|
||||
{
|
||||
if (User == null)
|
||||
if (uri.LocalPath != "/login" &&
|
||||
uri.LocalPath != "/passwordreset" &&
|
||||
uri.LocalPath != "/register")
|
||||
{
|
||||
<Login></Login>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (User.Status == UserStatus.Banned)
|
||||
if (User == null)
|
||||
{
|
||||
<BannedAlert></BannedAlert>
|
||||
}
|
||||
else if (User.Status == UserStatus.Disabled)
|
||||
{
|
||||
<DisabledAlert></DisabledAlert>
|
||||
}
|
||||
else if (User.Status == UserStatus.PasswordPending)
|
||||
{
|
||||
<PasswordChangeView></PasswordChangeView>
|
||||
}
|
||||
else if (User.Status == UserStatus.DataPending)
|
||||
{
|
||||
<UserDataSetView></UserDataSetView>
|
||||
<Login></Login>
|
||||
}
|
||||
else
|
||||
{
|
||||
@Body
|
||||
|
||||
<RatingPopup />
|
||||
if (User.Status == UserStatus.Banned)
|
||||
{
|
||||
<BannedAlert></BannedAlert>
|
||||
}
|
||||
else if (User.Status == UserStatus.Disabled)
|
||||
{
|
||||
<DisabledAlert></DisabledAlert>
|
||||
}
|
||||
else if (User.Status == UserStatus.PasswordPending)
|
||||
{
|
||||
<PasswordChangeView></PasswordChangeView>
|
||||
}
|
||||
else if (User.Status == UserStatus.DataPending)
|
||||
{
|
||||
<UserDataSetView></UserDataSetView>
|
||||
}
|
||||
else
|
||||
{
|
||||
@Body
|
||||
|
||||
<RatingPopup/>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uri.LocalPath == "/login")
|
||||
{
|
||||
<Login></Login>
|
||||
}
|
||||
else if (uri.LocalPath == "/register")
|
||||
{
|
||||
<Register></Register>
|
||||
}
|
||||
else if (uri.LocalPath == "/passwordreset")
|
||||
{
|
||||
<PasswordReset></PasswordReset>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uri.LocalPath == "/login")
|
||||
{
|
||||
<Login></Login>
|
||||
}
|
||||
else if (uri.LocalPath == "/register")
|
||||
{
|
||||
<Register></Register>
|
||||
}
|
||||
else if (uri.LocalPath == "/passwordreset")
|
||||
{
|
||||
<PasswordReset></PasswordReset>
|
||||
}
|
||||
<div class="modal d-block">
|
||||
<div class="modal-dialog modal-dialog-centered mw-900px">
|
||||
<div class="modal-content">
|
||||
<div class="pt-2 modal-body py-lg-10 px-lg-10">
|
||||
<h2>@(SmartTranslateService.Translate("Authenticating"))...</h2>
|
||||
<p class="mt-3 fw-normal fs-6">@(SmartTranslateService.Translate("Verifying token, loading user data"))</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -117,8 +134,8 @@
|
||||
<div class="modal-dialog modal-dialog-centered mw-900px">
|
||||
<div class="modal-content">
|
||||
<div class="pt-2 modal-body py-lg-10 px-lg-10">
|
||||
<h2>@(SmartTranslateService.Translate("Authenticating"))...</h2>
|
||||
<p class="mt-3 fw-normal fs-6">@(SmartTranslateService.Translate("Verifying token, loading user data"))</p>
|
||||
<h2>@(SmartTranslateService.Translate("Your ip has been banned"))</h2>
|
||||
<p class="mt-3 fw-normal fs-6">@(SmartTranslateService.Translate("Your ip address has been banned by an admin"))</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -142,6 +159,8 @@
|
||||
private User? User;
|
||||
private bool UserProcessed = false;
|
||||
|
||||
private bool IsIpBanned = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AddBodyAttribute("data-kt-app-page-loading", "on");
|
||||
@@ -170,6 +189,17 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
IsIpBanned = await IpBanService.IsBanned();
|
||||
|
||||
if(IsIpBanned)
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
await Event.On<Object>("ipBan.update", this, async o =>
|
||||
{
|
||||
IsIpBanned = await IpBanService.IsBanned();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
});
|
||||
|
||||
User = await IdentityService.Get();
|
||||
UserProcessed = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
Reference in New Issue
Block a user