mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +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.Web;
|
||||
using System.Web.Mvc;
|
||||
@@ -35,13 +36,16 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
||||
|
||||
public HttpPostedFileBase File { get; set; }
|
||||
public bool ResetSite { get; set; }
|
||||
public string SuperUserPassword { get; set; }
|
||||
|
||||
public override dynamic BuildEditor(dynamic shapeFactory) {
|
||||
return UpdateEditor(shapeFactory, null);
|
||||
}
|
||||
|
||||
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
||||
var viewModel = new UploadRecipeViewModel();
|
||||
var viewModel = new UploadRecipeViewModel {
|
||||
SuperUserName = _orchardServices.WorkContext.CurrentSite.SuperUser
|
||||
};
|
||||
|
||||
if (updater != null) {
|
||||
|
||||
@@ -50,9 +54,17 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
||||
|
||||
File = request.Files["RecipeFile"];
|
||||
ResetSite = viewModel.ResetSite;
|
||||
SuperUserPassword = viewModel.SuperUserPassword;
|
||||
|
||||
if (File == null || File.ContentLength == 0)
|
||||
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 {
|
||||
DropExistingTables = true,
|
||||
RecipeText = ReadRecipeFile(),
|
||||
AdminPassword = "password",
|
||||
AdminPassword = SuperUserPassword,
|
||||
AdminUsername = _orchardServices.WorkContext.CurrentSite.SuperUser,
|
||||
DatabaseConnectionString = _shellSettings.DataConnectionString,
|
||||
DatabaseProvider = _shellSettings.DataProvider,
|
||||
|
@@ -1,5 +1,8 @@
|
||||
namespace Orchard.ImportExport.ViewModels {
|
||||
public class UploadRecipeViewModel {
|
||||
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."))
|
||||
</div>
|
||||
<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>
|
||||
</fieldset>
|
Reference in New Issue
Block a user