mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Added super user password fields to UploadRecipe import action.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
@@ -35,13 +36,16 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
|||||||
|
|
||||||
public HttpPostedFileBase File { get; set; }
|
public HttpPostedFileBase File { get; set; }
|
||||||
public bool ResetSite { get; set; }
|
public bool ResetSite { get; set; }
|
||||||
|
public string SuperUserPassword { get; set; }
|
||||||
|
|
||||||
public override dynamic BuildEditor(dynamic shapeFactory) {
|
public override dynamic BuildEditor(dynamic shapeFactory) {
|
||||||
return UpdateEditor(shapeFactory, null);
|
return UpdateEditor(shapeFactory, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
||||||
var viewModel = new UploadRecipeViewModel();
|
var viewModel = new UploadRecipeViewModel {
|
||||||
|
SuperUserName = _orchardServices.WorkContext.CurrentSite.SuperUser
|
||||||
|
};
|
||||||
|
|
||||||
if (updater != null) {
|
if (updater != null) {
|
||||||
|
|
||||||
@@ -50,9 +54,17 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
|||||||
|
|
||||||
File = request.Files["RecipeFile"];
|
File = request.Files["RecipeFile"];
|
||||||
ResetSite = viewModel.ResetSite;
|
ResetSite = viewModel.ResetSite;
|
||||||
|
SuperUserPassword = viewModel.SuperUserPassword;
|
||||||
|
|
||||||
if (File == null || File.ContentLength == 0)
|
if (File == null || File.ContentLength == 0)
|
||||||
updater.AddModelError("RecipeFile", T("No recipe file selected."));
|
updater.AddModelError("RecipeFile", T("No recipe file selected."));
|
||||||
|
|
||||||
|
if (ResetSite) {
|
||||||
|
if(String.IsNullOrWhiteSpace(viewModel.SuperUserPassword))
|
||||||
|
updater.AddModelError("SuperUserPassword", T("Please specify a new password for the super user."));
|
||||||
|
else if(!String.Equals(viewModel.SuperUserPassword, viewModel.SuperUserPasswordConfirmation))
|
||||||
|
updater.AddModelError("SuperUserPassword", T("The passwords do not match."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +83,7 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
|||||||
var setupContext = new SetupContext {
|
var setupContext = new SetupContext {
|
||||||
DropExistingTables = true,
|
DropExistingTables = true,
|
||||||
RecipeText = ReadRecipeFile(),
|
RecipeText = ReadRecipeFile(),
|
||||||
AdminPassword = "password",
|
AdminPassword = SuperUserPassword,
|
||||||
AdminUsername = _orchardServices.WorkContext.CurrentSite.SuperUser,
|
AdminUsername = _orchardServices.WorkContext.CurrentSite.SuperUser,
|
||||||
DatabaseConnectionString = _shellSettings.DataConnectionString,
|
DatabaseConnectionString = _shellSettings.DataConnectionString,
|
||||||
DatabaseProvider = _shellSettings.DataProvider,
|
DatabaseProvider = _shellSettings.DataProvider,
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
namespace Orchard.ImportExport.ViewModels {
|
namespace Orchard.ImportExport.ViewModels {
|
||||||
public class UploadRecipeViewModel {
|
public class UploadRecipeViewModel {
|
||||||
public bool ResetSite { get; set; }
|
public bool ResetSite { get; set; }
|
||||||
|
public string SuperUserName { get; set; }
|
||||||
|
public string SuperUserPassword { get; set; }
|
||||||
|
public string SuperUserPasswordConfirmation { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,16 @@
|
|||||||
@Html.Hint(T("Check this option to reset your site before executing the uploaded recipe."))
|
@Html.Hint(T("Check this option to reset your site before executing the uploaded recipe."))
|
||||||
</div>
|
</div>
|
||||||
<div data-controllerid="@Html.FieldIdFor(m => m.ResetSite)">
|
<div data-controllerid="@Html.FieldIdFor(m => m.ResetSite)">
|
||||||
|
<div>
|
||||||
|
@Html.LabelFor(m => m.SuperUserPassword, T("Super User Password"))
|
||||||
|
@Html.PasswordFor(m => m.SuperUserPassword, new {@class = "text medium"})
|
||||||
|
@Html.Hint(T("Specify a new password for the super user in case your recipe doesn't contain the current super user."))
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
@Html.LabelFor(m => m.SuperUserPasswordConfirmation, T("Confirm Super User Password"))
|
||||||
|
@Html.PasswordFor(m => m.SuperUserPasswordConfirmation, new { @class = "text medium" })
|
||||||
|
@Html.Hint(T("Repeat the password to make sure you didn't mistype anything."))
|
||||||
|
</div>
|
||||||
<div class="message message-Warning">@T("This will delete your database tables. Please consider creating a backup first.")</div>
|
<div class="message message-Warning">@T("This will delete your database tables. Please consider creating a backup first.")</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
Reference in New Issue
Block a user