-
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.
Added recipe steps for user and email settings
- Loading branch information
Showing
10 changed files
with
254 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/OrchardCore.Modules/OrchardCore.Email/Recipes/SmtpSettingsStep.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,48 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using OrchardCore.Email; | ||
using OrchardCore.Entities; | ||
using OrchardCore.Recipes.Models; | ||
using OrchardCore.Recipes.Services; | ||
using OrchardCore.Settings; | ||
|
||
namespace OrchardCore.Email.Recipes | ||
{ | ||
/// <summary> | ||
/// This recipe step sets general login settings. | ||
/// </summary> | ||
public class SmtpSettingsStep : IRecipeStepHandler | ||
{ | ||
private readonly ISiteService _siteService; | ||
|
||
public SmtpSettingsStep(ISiteService siteService) | ||
=> _siteService = siteService; | ||
|
||
public async Task ExecuteAsync(RecipeExecutionContext context) | ||
{ | ||
if (!string.Equals(context.Name, nameof(SmtpSettings), StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return; | ||
} | ||
|
||
var model = context.Step.ToObject<SmtpSettingsStepModel>(); | ||
|
||
var site = await _siteService.LoadSiteSettingsAsync(); | ||
var settings = site.As<SmtpSettings>(); | ||
settings.DefaultSender = model.DefaultSender; | ||
settings.DeliveryMethod = model.DeliveryMethod; | ||
settings.PickupDirectoryLocation = model.PickupDirectoryLocation; | ||
settings.Host = model.Host; | ||
settings.Port = model.Port; | ||
settings.AutoSelectEncryption = model.AutoSelectEncryption; | ||
settings.RequireCredentials = model.RequireCredentials; | ||
settings.UseDefaultCredentials = model.UseDefaultCredentials; | ||
settings.EncryptionMethod = model.EncryptionMethod; | ||
settings.UserName = model.UserName; | ||
settings.Password = model.Password; | ||
site.Put<SmtpSettings>(settings); | ||
await _siteService.UpdateSiteSettingsAsync(site); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/OrchardCore.Modules/OrchardCore.Email/Recipes/SmtpSettingsStepModel.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,19 @@ | ||
using OrchardCore.Email; | ||
|
||
namespace OrchardCore.Email | ||
{ | ||
public class SmtpSettingsStepModel | ||
{ | ||
public string DefaultSender { get; set; } | ||
public SmtpDeliveryMethod DeliveryMethod { get; set; } | ||
public string PickupDirectoryLocation { get; set; } | ||
public string Host { get; set; } | ||
public int Port { get; set; } = 25; | ||
public bool AutoSelectEncryption { get; set; } | ||
public bool RequireCredentials { get; set; } | ||
public bool UseDefaultCredentials { get; set; } | ||
public SmtpEncryptionMethod EncryptionMethod { get; set; } | ||
public string UserName { get; set; } | ||
public string Password { get; set; } | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/OrchardCore.Modules/OrchardCore.Users/Recipes/LoginSettingsStep.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,42 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using OrchardCore.Entities; | ||
using OrchardCore.Recipes.Models; | ||
using OrchardCore.Recipes.Services; | ||
using OrchardCore.Settings; | ||
using OrchardCore.Users.Models; | ||
|
||
namespace OrchardCore.Users.Recipes | ||
{ | ||
/// <summary> | ||
/// This recipe step sets general login settings. | ||
/// </summary> | ||
public class LoginSettingsStep : IRecipeStepHandler | ||
{ | ||
private readonly ISiteService _siteService; | ||
|
||
public LoginSettingsStep(ISiteService siteService) | ||
=> _siteService = siteService; | ||
|
||
public async Task ExecuteAsync(RecipeExecutionContext context) | ||
{ | ||
if (!string.Equals(context.Name, nameof(LoginSettings), StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return; | ||
} | ||
|
||
var model = context.Step.ToObject<LoginSettingsStepModel>(); | ||
|
||
var site = await _siteService.LoadSiteSettingsAsync(); | ||
var settings = site.As<LoginSettings>(); | ||
settings.UseSiteTheme = model.UseSiteTheme; | ||
settings.UseExternalProviderIfOnlyOneDefined = model.UseExternalProviderIfOnlyOneDefined; | ||
settings.DisableLocalLogin = model.DisableLocalLogin; | ||
settings.UseScriptToSyncRoles = model.UseScriptToSyncRoles; | ||
settings.SyncRolesScript = model.SyncRolesScript; | ||
site.Put<LoginSettings>(settings); | ||
await _siteService.UpdateSiteSettingsAsync(site); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/OrchardCore.Modules/OrchardCore.Users/Recipes/LoginSettingsStepModel.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,15 @@ | ||
namespace OrchardCore.Users | ||
{ | ||
public class LoginSettingsStepModel | ||
{ | ||
public bool UseSiteTheme { get; set; } | ||
|
||
public bool UseExternalProviderIfOnlyOneDefined { get; set; } | ||
|
||
public bool DisableLocalLogin { get; set; } | ||
|
||
public bool UseScriptToSyncRoles { get; set; } | ||
|
||
public string SyncRolesScript { get; set; } | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/OrchardCore.Modules/OrchardCore.Users/Recipes/ResetPasswordSettingsStep.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,39 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using OrchardCore.Entities; | ||
using OrchardCore.Recipes.Models; | ||
using OrchardCore.Recipes.Services; | ||
using OrchardCore.Settings; | ||
using OrchardCore.Users.Models; | ||
|
||
namespace OrchardCore.Users.Recipes | ||
{ | ||
/// <summary> | ||
/// This recipe step sets general reset password settings. | ||
/// </summary> | ||
public class ResetPasswordSettingsStep : IRecipeStepHandler | ||
{ | ||
private readonly ISiteService _siteService; | ||
|
||
public ResetPasswordSettingsStep(ISiteService siteService) | ||
=> _siteService = siteService; | ||
|
||
public async Task ExecuteAsync(RecipeExecutionContext context) | ||
{ | ||
if (!string.Equals(context.Name, nameof(ResetPasswordSettings), StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return; | ||
} | ||
|
||
var model = context.Step.ToObject<ResetPasswordSettingsStepModel>(); | ||
|
||
var site = await _siteService.LoadSiteSettingsAsync(); | ||
var settings = site.As<ResetPasswordSettings>(); | ||
settings.AllowResetPassword = model.AllowResetPassword; | ||
settings.UseSiteTheme = model.UseSiteTheme; | ||
site.Put<ResetPasswordSettings>(settings); | ||
await _siteService.UpdateSiteSettingsAsync(site); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/OrchardCore.Modules/OrchardCore.Users/Recipes/ResetPasswordSettingsStepModel.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,8 @@ | ||
namespace OrchardCore.Users | ||
{ | ||
public class ResetPasswordSettingsStepModel | ||
{ | ||
public bool AllowResetPassword { get; set; } | ||
public bool UseSiteTheme { get; set; } | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/OrchardCore.Themes/TheTheme/Views/OrchardCore.Users/ResetPassword/ForgotPassword.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,28 @@ | ||
@model OrchardCore.Users.ViewModels.ForgotPasswordViewModel | ||
|
||
@{ | ||
ViewLayout = "Layout__Login"; | ||
} | ||
|
||
<h2>@T["Forgot password?"]</h2> | ||
<h4>@T["Please check your email or user name to reset your password."]</h4> | ||
<hr /> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
<form asp-controller="ResetPassword" asp-action="ForgotPassword" method="post" class="form-horizontal"> | ||
<div asp-validation-summary="All" class="text-danger"></div> | ||
<div class="form-group"> | ||
<label asp-for="UserIdentifier" class="col-md-4 control-label">@T["Email or user name Melon"]</label> | ||
<div class="col-md-9"> | ||
<input asp-for="UserIdentifier" class="form-control" /> | ||
</div> | ||
</div> | ||
@await RenderSectionAsync("AfterForgotPassword", required: false) | ||
<div class="form-group"> | ||
<div class="col-md-offset-4 col-md-8"> | ||
<button type="submit" class="btn btn-primary">@T["Submit"]</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> |
6 changes: 6 additions & 0 deletions
6
...e.Themes/TheTheme/Views/OrchardCore.Users/ResetPassword/ForgotPasswordConfirmation.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,6 @@ | ||
@{ | ||
ViewLayout = "Layout__Login"; | ||
} | ||
|
||
<h1>@T["Forgot Password confirmation Melon"]</h1> | ||
<p>@T["Please check your email to reset your password."]</p> |
40 changes: 40 additions & 0 deletions
40
src/OrchardCore.Themes/TheTheme/Views/OrchardCore.Users/ResetPassword/ResetPassword.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,40 @@ | ||
@model OrchardCore.Users.ViewModels.ResetPasswordViewModel | ||
|
||
@{ | ||
ViewLayout = "Layout__Login"; | ||
} | ||
|
||
<form asp-controller="ResetPassword" asp-action="ResetPassword" method="post" class="form-horizontal"> | ||
<h4>@T["Reset password"]</h4> | ||
<hr /> | ||
<div asp-validation-summary="All" class="text-danger"></div> | ||
<div class="form-group"> | ||
<label asp-for="Email" class="col-md-3 control-label">@T["Email"]</label> | ||
<div class="col-md-9"> | ||
<input asp-for="Email" class="form-control" /> | ||
<span asp-validation-for="Email" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="NewPassword" class="col-md-3 control-label">@T["New password"]</label> | ||
<div class="col-md-9"> | ||
<input asp-for="NewPassword" class="form-control" /> | ||
<div id="passwordStrength"></div> | ||
<span asp-validation-for="NewPassword" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="PasswordConfirmation" class="col-md-3 control-label">@T["New password confirmation Melon"]</label> | ||
<div class="col-md-9"> | ||
<input asp-for="PasswordConfirmation" class="form-control" /> | ||
<span asp-validation-for="PasswordConfirmation" class="text-danger"></span> | ||
</div> | ||
</div> | ||
@await RenderSectionAsync("AfterResetPassword", required: false) | ||
<input asp-for="ResetToken" type="hidden" /> | ||
<div class="form-group"> | ||
<div class="col-md-offset-3 col-md-9"> | ||
<button type="submit" class="btn btn-primary">@T["Reset password"]</button> | ||
</div> | ||
</div> | ||
</form> |
9 changes: 9 additions & 0 deletions
9
...re.Themes/TheTheme/Views/OrchardCore.Users/ResetPassword/ResetPasswordConfirmation.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,9 @@ | ||
@{ | ||
ViewLayout = "Layout__Login"; | ||
} | ||
|
||
<h1>@T["Reset Password"]</h1> | ||
<p> | ||
@T["Your password has been reset. Melon"] | ||
@T["Please "]<a asp-route-area="OrchardCore.Users" asp-controller="Account" asp-action="Login">@T["Click here to log in"]</a> | ||
</p> |