forked from OrchardCMS/OrchardCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing that a captcha is required on external login and registration,…
… renaming `IExternalLoginEventHandler` to `IExternalLoginUserHandler` (Lombiq Technologies: GOV-44) (OrchardCMS#17490) --------- Co-authored-by: Mike Alhayek <mike@crestapps.com>
- Loading branch information
1 parent
6b6e0d4
commit 55c5809
Showing
6 changed files
with
88 additions
and
62 deletions.
There are no files selected for viewing
21 changes: 18 additions & 3 deletions
21
src/OrchardCore.Modules/OrchardCore.ReCaptcha/Users/Handlers/LoginFormEventEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using OrchardCore.ReCaptcha.Services; | ||
using OrchardCore.Users; | ||
using OrchardCore.Users.Events; | ||
|
||
namespace OrchardCore.ReCaptcha.Users.Handlers; | ||
|
||
public sealed class LoginFormEventEventHandler : LoginFormEventBase | ||
{ | ||
private readonly ReCaptchaService _reCaptchaService; | ||
private readonly SignInManager<IUser> _signInManager; | ||
|
||
public LoginFormEventEventHandler(ReCaptchaService reCaptchaService) | ||
public LoginFormEventEventHandler( | ||
ReCaptchaService reCaptchaService, | ||
SignInManager<IUser> signInManager) | ||
{ | ||
_reCaptchaService = reCaptchaService; | ||
_signInManager = signInManager; | ||
} | ||
|
||
public override Task LoggingInAsync(string userName, Action<string, string> reportError) | ||
=> _reCaptchaService.ValidateCaptchaAsync(reportError); | ||
public override async Task LoggingInAsync(string userName, Action<string, string> reportError) | ||
{ | ||
// When logging in via an external provider, authentication security is already handled by the provider. | ||
// Therefore, using a CAPTCHA is unnecessary and impractical, as users wouldn't be able to complete it anyway. | ||
if (await _signInManager.GetExternalLoginInfoAsync() != null) | ||
{ | ||
return; | ||
} | ||
|
||
await _reCaptchaService.ValidateCaptchaAsync(reportError); | ||
} | ||
} |
21 changes: 18 additions & 3 deletions
21
src/OrchardCore.Modules/OrchardCore.ReCaptcha/Users/Handlers/RegistrationFormEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using OrchardCore.ReCaptcha.Services; | ||
using OrchardCore.Users; | ||
using OrchardCore.Users.Events; | ||
|
||
namespace OrchardCore.ReCaptcha.Users.Handlers; | ||
|
||
public sealed class RegistrationFormEventHandler : RegistrationFormEventsBase | ||
{ | ||
private readonly ReCaptchaService _reCaptchaService; | ||
private readonly SignInManager<IUser> _signInManager; | ||
|
||
public RegistrationFormEventHandler(ReCaptchaService reCaptchaService) | ||
public RegistrationFormEventHandler( | ||
ReCaptchaService reCaptchaService, | ||
SignInManager<IUser> signInManager) | ||
{ | ||
_reCaptchaService = reCaptchaService; | ||
_signInManager = signInManager; | ||
} | ||
|
||
public override Task RegistrationValidationAsync(Action<string, string> reportError) | ||
=> _reCaptchaService.ValidateCaptchaAsync(reportError); | ||
public override async Task RegistrationValidationAsync(Action<string, string> reportError) | ||
{ | ||
// When logging in via an external provider, authentication security is already handled by the provider. | ||
// Therefore, using a CAPTCHA is unnecessary and impractical, as users wouldn't be able to complete it anyway. | ||
if (await _signInManager.GetExternalLoginInfoAsync() != null) | ||
{ | ||
return; | ||
} | ||
|
||
await _reCaptchaService.ValidateCaptchaAsync(reportError); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.