Hooked up support for overwriting

Made DMU web service check for logged in user if no credentials are passed in
This commit is contained in:
Matt@MBP13-PC
2012-08-08 09:08:09 -01:00
parent a989ea77ff
commit ccd56f5594
3 changed files with 15 additions and 19 deletions

View File

@@ -170,10 +170,10 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
var overlay = $("<div class='upload-overlay'>" +
"<div class='upload-panel'>" +
instructions +
"<form action=\"/base/FolderBrowserService/Upload/" + this._parentId + "\" method=\"post\" enctype=\"multipart/form-data\">" +
"<form action=\"/umbraco/webservices/MediaUploader.ashx?format=json&action=upload&parentNodeId=" + this._parentId + "\" method=\"post\" enctype=\"multipart/form-data\">" +
"<input id='fileupload' type='file' name='file' multiple>" +
"<input type='hidden' name='name' />" +
"<input type='hidden' name='overwriteExisting' />" +
"<input type='hidden' name='replaceExisting' />" +
"</form>" +
"<ul class='queued' data-bind='foreach: queued'><li>" +
"<input type='text' class='label' data-bind=\"value: name, valueUpdate: 'afterkeydown', enable: progress() == 0\" />" +
@@ -181,8 +181,8 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
"<a href='' data-bind='click: cancel'><img src='images/delete.png' /></a>" +
"</li></ul>" +
"<button class='button upload' data-bind='enable: queued().length > 0'>Upload</button>" +
"<input type='checkbox' id='overwriteExisting' />" +
"<label for='overwriteExisting'>Overwrite existing?</label>" +
"<input type='checkbox' id='replaceExisting' />" +
"<label for='replaceExisting'>Overwrite existing?</label>" +
"<a href='#' class='cancel'>Cancel</a>" +
"</div>" +
"</div>");
@@ -243,8 +243,8 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
$("#fileupload").fileUploader("uploadAll");
});
$(".upload-overlay #overwriteExisting").click(function() {
$("input[name=overwriteExisting]").val($(this).is(":checked"));
$(".upload-overlay #replaceExisting").click(function() {
$("input[name=replaceExisting]").val($(this).is(":checked"));
});
$(".upload-overlay .cancel").click(function (e) {

View File

@@ -124,21 +124,11 @@ namespace Umbraco.Web.UI.Controls
Controls.Add(panel);
var user = User.GetCurrent();
var ticket = new FormsAuthenticationTicket(1,
user != null ? user.LoginName : "",
DateTime.Now,
DateTime.Now,
false,
"");
Page.ClientScript.RegisterStartupScript(typeof(FolderBrowser),
"RegisterFolderBrowsers",
string.Format("$(function () {{ $(\".umbFolderBrowser\").folderBrowser({{ umbracoPath : '{0}', basePath : '{1}', username: '{2}', ticket: '{3}' }}); }});",
string.Format("$(function () {{ $(\".umbFolderBrowser\").folderBrowser({{ umbracoPath : '{0}', basePath : '{1}' }}); }});",
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
IOHelper.ResolveUrl(SystemDirectories.Base),
user != null ? user.LoginName : "",
FormsAuthentication.Encrypt(ticket)),
IOHelper.ResolveUrl(SystemDirectories.Base)),
true);
}

View File

@@ -144,7 +144,8 @@ namespace umbraco.presentation.umbraco.webservices
}
// Check whether to replace existing
bool replaceExisting = (context.Request["replaceExisting"] == "1");
var parsed = false;
bool replaceExisting = (context.Request["replaceExisting"] == "1" || (bool.TryParse(context.Request["replaceExisting"], out parsed) && parsed));
// loop through uploaded files
for (var j = 0; j < context.Request.Files.Count; j++)
@@ -224,6 +225,11 @@ namespace umbraco.presentation.umbraco.webservices
if (isValid)
AuthenticatedUser = user;
}
else if (User.GetCurrent() != null)
{
isValid = true;
AuthenticatedUser = User.GetCurrent();
}
return isValid;
}