-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
17 changed files
with
322 additions
and
115 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/OrchardCore.Modules/OrchardCore.ReCaptcha/Drivers/ReCaptchaLoginFormDisplayDriver.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Threading.Tasks; | ||
using OrchardCore.DisplayManagement.Handlers; | ||
using OrchardCore.DisplayManagement.Views; | ||
using OrchardCore.ReCaptcha.Configuration; | ||
using OrchardCore.ReCaptcha.Services; | ||
using OrchardCore.Settings; | ||
using OrchardCore.Users.Models; | ||
|
||
namespace OrchardCore.ReCaptcha.Drivers; | ||
|
||
public class ReCaptchaLoginFormDisplayDriver : DisplayDriver<LoginForm> | ||
{ | ||
private readonly ISiteService _siteService; | ||
private readonly ReCaptchaService _reCaptchaService; | ||
|
||
public ReCaptchaLoginFormDisplayDriver( | ||
ISiteService siteService, | ||
ReCaptchaService reCaptchaService) | ||
{ | ||
_siteService = siteService; | ||
_reCaptchaService = reCaptchaService; | ||
} | ||
|
||
public override async Task<IDisplayResult> EditAsync(LoginForm model, BuildEditorContext context) | ||
{ | ||
var _reCaptchaSettings = (await _siteService.GetSiteSettingsAsync()).As<ReCaptchaSettings>(); | ||
|
||
if (!_reCaptchaSettings.IsValid() || !_reCaptchaService.IsThisARobot()) | ||
{ | ||
return null; | ||
} | ||
|
||
return View("LoginFormReCaptcha_Edit", model).Location("Content:after"); | ||
} | ||
} |
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
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
3 changes: 3 additions & 0 deletions
3
src/OrchardCore.Modules/OrchardCore.ReCaptcha/Views/LoginFormReCaptcha.Edit.cshtml
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="mb-3"> | ||
<captcha mode="AlwaysShow" language="@Orchard.CultureName()" /> | ||
</div> |
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
29 changes: 29 additions & 0 deletions
29
src/OrchardCore.Modules/OrchardCore.Users/Drivers/ForgotPasswordLoginFormDisplayDriver.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Threading.Tasks; | ||
using OrchardCore.DisplayManagement.Handlers; | ||
using OrchardCore.DisplayManagement.Views; | ||
using OrchardCore.Settings; | ||
using OrchardCore.Users.Models; | ||
|
||
namespace OrchardCore.Users.Drivers; | ||
|
||
public class ForgotPasswordLoginFormDisplayDriver : DisplayDriver<LoginForm> | ||
{ | ||
private readonly ISiteService _siteService; | ||
|
||
public ForgotPasswordLoginFormDisplayDriver(ISiteService siteService) | ||
{ | ||
_siteService = siteService; | ||
} | ||
|
||
public override async Task<IDisplayResult> EditAsync(LoginForm model, BuildEditorContext context) | ||
{ | ||
var settings = (await _siteService.GetSiteSettingsAsync()).As<ResetPasswordSettings>(); | ||
|
||
if (!settings.AllowResetPassword) | ||
{ | ||
return null; | ||
} | ||
|
||
return View("LoginFormForgotPassword_Edit", model).Location("Links:5"); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/OrchardCore.Modules/OrchardCore.Users/Drivers/LoginFormDisplayDriver.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Threading.Tasks; | ||
using OrchardCore.DisplayManagement.Handlers; | ||
using OrchardCore.DisplayManagement.ModelBinding; | ||
using OrchardCore.DisplayManagement.Views; | ||
using OrchardCore.Entities; | ||
using OrchardCore.Users.Models; | ||
using OrchardCore.Users.ViewModels; | ||
|
||
namespace OrchardCore.Users.Drivers; | ||
|
||
public class LoginFormDisplayDriver : DisplayDriver<LoginForm> | ||
{ | ||
public override IDisplayResult Edit(LoginForm model) | ||
{ | ||
return Initialize<LoginViewModel>("LoginFormCredentials_Edit", vm => | ||
{ | ||
vm.UserName = model.UserName; | ||
vm.RememberMe = model.RememberMe; | ||
}).Location("Content"); | ||
} | ||
|
||
public override async Task<IDisplayResult> UpdateAsync(LoginForm model, IUpdateModel updater) | ||
{ | ||
var viewModel = new LoginViewModel(); | ||
|
||
await updater.TryUpdateModelAsync(viewModel, Prefix); | ||
|
||
model.UserName = viewModel.UserName; | ||
model.Password = viewModel.Password; | ||
model.RememberMe = viewModel.RememberMe; | ||
|
||
model.Put(viewModel); | ||
|
||
return Edit(model); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/OrchardCore.Modules/OrchardCore.Users/Drivers/RegisterUserLoginFormDisplayDriver.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Threading.Tasks; | ||
using OrchardCore.DisplayManagement.Handlers; | ||
using OrchardCore.DisplayManagement.Views; | ||
using OrchardCore.Settings; | ||
using OrchardCore.Users.Models; | ||
|
||
namespace OrchardCore.Users.Drivers; | ||
|
||
public class RegisterUserLoginFormDisplayDriver : DisplayDriver<LoginForm> | ||
{ | ||
private readonly ISiteService _siteService; | ||
|
||
public RegisterUserLoginFormDisplayDriver(ISiteService siteService) | ||
{ | ||
_siteService = siteService; | ||
} | ||
|
||
public override async Task<IDisplayResult> EditAsync(LoginForm model, BuildEditorContext context) | ||
{ | ||
var settings = (await _siteService.GetSiteSettingsAsync()).As<RegistrationSettings>(); | ||
|
||
if (settings.UsersCanRegister != UserRegistrationType.AllowRegistration) | ||
{ | ||
return null; | ||
} | ||
|
||
return View("LoginFormRegisterUser_Edit", model).Location("Links:10"); | ||
} | ||
} |
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.