Implemented ip filtering to detect datacenter and vpn ips
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
@inject DynamicBackgroundService DynamicBackgroundService
|
||||
@inject KeyListenerService KeyListenerService
|
||||
@inject ConfigService ConfigService
|
||||
@inject IpVerificationService IpVerificationService
|
||||
|
||||
@{
|
||||
var uri = new Uri(NavigationManager.Uri);
|
||||
@@ -46,9 +47,35 @@
|
||||
|
||||
<DefaultLayout>
|
||||
<SoftErrorBoundary>
|
||||
@if (!IsIpBanned)
|
||||
@if (UserProcessed)
|
||||
{
|
||||
if (UserProcessed)
|
||||
if (IsIpBanned)
|
||||
{
|
||||
<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("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>
|
||||
</div>
|
||||
}
|
||||
else if (IsIpSuspicious)
|
||||
{
|
||||
<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("Your ip his blocked. VPNs and Datacenter IPs are prohibited from accessing this site"))</h2>
|
||||
<p class="mt-3 fw-normal fs-6">@(SmartTranslateService.Translate("Please disable your vpn or proxy and try it again"))</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uri.LocalPath != "/login" &&
|
||||
uri.LocalPath != "/passwordreset" &&
|
||||
@@ -102,19 +129,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<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
|
||||
{
|
||||
@@ -122,8 +136,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("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>
|
||||
<h2>@(SmartTranslateService.Translate("Authenticating"))...</h2>
|
||||
<p class="mt-3 fw-normal fs-6">@(SmartTranslateService.Translate("Verifying token, loading user data"))</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -137,6 +151,7 @@
|
||||
{
|
||||
private bool UserProcessed = false;
|
||||
private bool IsIpBanned = false;
|
||||
private bool IsIpSuspicious = false;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
@@ -146,11 +161,6 @@
|
||||
{
|
||||
DynamicBackgroundService.OnBackgroundImageChanged += async (_, _) => { await InvokeAsync(StateHasChanged); };
|
||||
|
||||
IsIpBanned = await IpBanService.IsBanned();
|
||||
|
||||
if (IsIpBanned)
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
await Event.On<Object>("ipBan.update", this, async _ =>
|
||||
{
|
||||
IsIpBanned = await IpBanService.IsBanned();
|
||||
@@ -158,6 +168,10 @@
|
||||
});
|
||||
|
||||
await IdentityService.Load();
|
||||
|
||||
IsIpBanned = await IpBanService.IsBanned();
|
||||
IsIpSuspicious = await IpVerificationService.IsDatacenterOrVpn(IdentityService.Ip);
|
||||
|
||||
UserProcessed = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user