mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-09-01 23:27:02 +00:00
Rewrite captcha system (#754)
Rewrite captcha and remove many unused directives
This commit is contained in:
parent
aefecc7b12
commit
3aa9033b67
36 changed files with 101 additions and 111 deletions
|
@ -3,10 +3,10 @@ using System.Web;
|
|||
using JetBrains.Annotations;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Captcha;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
|
@ -18,8 +18,12 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
|
|||
|
||||
public class LoginForm : BaseLayout
|
||||
{
|
||||
public LoginForm(DatabaseContext database) : base(database)
|
||||
{}
|
||||
private readonly ICaptchaService captchaService;
|
||||
|
||||
public LoginForm(DatabaseContext database, ICaptchaService captchaService) : base(database)
|
||||
{
|
||||
this.captchaService = captchaService;
|
||||
}
|
||||
|
||||
public string? Error { get; private set; }
|
||||
|
||||
|
@ -38,7 +42,7 @@ public class LoginForm : BaseLayout
|
|||
return this.Page();
|
||||
}
|
||||
|
||||
if (!await this.Request.CheckCaptchaValidity())
|
||||
if (!await this.captchaService.VerifyCaptcha(this.Request))
|
||||
{
|
||||
this.Error = this.Translate(ErrorStrings.CaptchaFailed);
|
||||
return this.Page();
|
||||
|
|
|
@ -2,9 +2,9 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using JetBrains.Annotations;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Captcha;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
|
@ -15,8 +15,12 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
|
|||
|
||||
public class RegisterForm : BaseLayout
|
||||
{
|
||||
public RegisterForm(DatabaseContext database) : base(database)
|
||||
{ }
|
||||
private readonly ICaptchaService captchaService;
|
||||
|
||||
public RegisterForm(DatabaseContext database, ICaptchaService captchaService) : base(database)
|
||||
{
|
||||
this.captchaService = captchaService;
|
||||
}
|
||||
|
||||
public string? Error { get; private set; }
|
||||
|
||||
|
@ -68,7 +72,7 @@ public class RegisterForm : BaseLayout
|
|||
return this.Page();
|
||||
}
|
||||
|
||||
if (!await this.Request.CheckCaptchaValidity())
|
||||
if (!await this.captchaService.VerifyCaptcha(this.Request))
|
||||
{
|
||||
this.Error = this.Translate(ErrorStrings.CaptchaFailed);
|
||||
return this.Page();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue