Converts create.aspx to have the correct webforms file/class structure, fixed logging for userTask,
fixed issue with last regex fix for xss
This commit is contained in:
@@ -289,6 +289,13 @@
|
||||
<DependentUpon>loadStarterKits.ascx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Umbraco\Create.aspx.cs">
|
||||
<DependentUpon>create.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Create.aspx.designer.cs">
|
||||
<DependentUpon>create.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\developer\Macros\EditMacro.aspx.cs">
|
||||
<DependentUpon>editMacro.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
|
||||
44
src/Umbraco.Web.UI/umbraco/Create.aspx.cs
Normal file
44
src/Umbraco.Web.UI/umbraco/Create.aspx.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco
|
||||
{
|
||||
public partial class Create : global::umbraco.cms.presentation.Create
|
||||
{
|
||||
|
||||
//protected override void OnLoad(EventArgs e)
|
||||
//{
|
||||
// if (SecurityCheck(Request.QueryString["nodeType"]))
|
||||
// {
|
||||
// //if we're allowed, then continue
|
||||
// base.OnLoad(e);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //otherwise show an error
|
||||
// UI.Visible = false;
|
||||
// AccessError.Visible = true;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private bool SecurityCheck(string treeAlias)
|
||||
//{
|
||||
// var tree = TreeDefinitionCollection.Instance.FindTree(treeAlias);
|
||||
// if (tree != null)
|
||||
// {
|
||||
// //does the current user have access to the current app?
|
||||
// var user = this.getUser();
|
||||
// var userApps = user.Applications;
|
||||
// return userApps.Any(x => x.alias.InvariantEquals(tree.App.alias));
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.3053
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace umbraco.cms.presentation {
|
||||
namespace Umbraco.Web.UI.Umbraco {
|
||||
|
||||
|
||||
public partial class Create {
|
||||
|
||||
/// <summary>
|
||||
/// UI control.
|
||||
/// AccessError control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder UI;
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder AccessError;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<%@ Page Language="c#" MasterPageFile="masterpages/umbracoDialog.Master" Codebehind="create.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.Create" %>
|
||||
<%@ Page Language="c#" MasterPageFile="masterpages/umbracoDialog.Master" Codebehind="Create.aspx.cs" AutoEventWireup="True" Inherits="Umbraco.Web.UI.Umbraco.Create" %>
|
||||
|
||||
<%@ Register Namespace="umbraco" TagPrefix="umb" Assembly="umbraco" %>
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="body">
|
||||
<asp:PlaceHolder ID="UI" runat="server"></asp:PlaceHolder>
|
||||
<asp:PlaceHolder runat="server" Visible="False" ID="AccessError">
|
||||
<div class="error">
|
||||
<p>
|
||||
The current user does not have access to create this type of object
|
||||
</p>
|
||||
</div>
|
||||
</asp:PlaceHolder>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="footer">
|
||||
|
||||
@@ -13,7 +13,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
|
||||
function getHashFragment(frag) {
|
||||
//tests for xss and ensures only the first alphanumeric chars are matched
|
||||
var result = hashFragmentRegex.exec(frag);
|
||||
if (result.length > 0) {
|
||||
if (result != null && result.length > 0) {
|
||||
return result[0];
|
||||
}
|
||||
return "";
|
||||
|
||||
@@ -342,6 +342,9 @@
|
||||
<Compile Include="umbraco.presentation\MacroCacheContent.cs" />
|
||||
<Compile Include="umbraco.presentation\macroCacheRefresh.cs" />
|
||||
<Compile Include="umbraco.presentation\ScriptingMacroResult.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\create.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Macros\editMacro.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
@@ -980,13 +983,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\SendPublish.aspx.designer.cs">
|
||||
<DependentUpon>SendPublish.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\create.aspx.cs">
|
||||
<DependentUpon>create.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\create.aspx.designer.cs">
|
||||
<DependentUpon>create.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\create\content.ascx.cs">
|
||||
<DependentUpon>content.ascx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1935,7 +1931,9 @@
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\AssignDomain.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\create.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\create.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\cruds.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\editMacro.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\emptyTrashcan.aspx" />
|
||||
@@ -2006,9 +2004,6 @@
|
||||
<Content Include="umbraco.presentation\umbraco\translation\preview.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\translation\translationTasks.dtd" />
|
||||
<Content Include="umbraco.presentation\umbraco\translation\xml.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\create.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\create\content.ascx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<%@ Page Language="c#" MasterPageFile="masterpages/umbracoDialog.Master" Codebehind="create.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.Create" %>
|
||||
|
||||
<%@ Register Namespace="umbraco" TagPrefix="umb" Assembly="umbraco" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server">
|
||||
<script type="text/javascript">
|
||||
|
||||
var preExecute;
|
||||
|
||||
function doSubmit() { document.forms[0].submit(); }
|
||||
|
||||
var functionsFrame = this;
|
||||
var tabFrame = this;
|
||||
var isDialog = true;
|
||||
var submitOnEnter = true;
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="body">
|
||||
<asp:PlaceHolder ID="UI" runat="server"></asp:PlaceHolder>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="footer">
|
||||
<script type="text/javascript">
|
||||
function setFocusOnText() {
|
||||
for (var i = 0; i < document.forms[0].length; i++) {
|
||||
if (document.forms[0][i].type == 'text') {
|
||||
document.forms[0][i].focus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<%if (!IsPostBack) { %>
|
||||
setTimeout("setFocusOnText()", 100);
|
||||
<%} %>
|
||||
</script>
|
||||
</asp:Content>
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@@ -11,33 +11,34 @@ using System.Web.UI.HtmlControls;
|
||||
|
||||
using System.Xml.XPath;
|
||||
using System.Xml;
|
||||
using umbraco.IO;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace umbraco.cms.presentation
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for create.
|
||||
/// </summary>
|
||||
public partial class Create : BasePages.UmbracoEnsuredPage
|
||||
|
||||
public class Create : BasePages.UmbracoEnsuredPage
|
||||
{
|
||||
protected umbWindow createWindow;
|
||||
protected System.Web.UI.WebControls.Label helpText;
|
||||
protected System.Web.UI.WebControls.TextBox rename;
|
||||
protected System.Web.UI.WebControls.Label Label1;
|
||||
protected System.Web.UI.WebControls.ListBox nodeType;
|
||||
protected Label helpText;
|
||||
protected TextBox rename;
|
||||
protected Label Label1;
|
||||
protected ListBox nodeType;
|
||||
protected PlaceHolder UI;
|
||||
|
||||
protected void Page_Load(object sender, System.EventArgs e)
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
// Load create definitions
|
||||
string nodeType = Request.QueryString["nodeType"];
|
||||
base.OnLoad(e);
|
||||
|
||||
XmlDocument createDef = new XmlDocument();
|
||||
XmlTextReader defReader = new XmlTextReader(IOHelper.MapPath(SystemFiles.CreateUiXml));
|
||||
// Load create definitions
|
||||
var nodeType = Request.QueryString["nodeType"];
|
||||
|
||||
var createDef = new XmlDocument();
|
||||
var defReader = new XmlTextReader(IOHelper.MapPath(SystemFiles.CreateUiXml));
|
||||
createDef.Load(defReader);
|
||||
defReader.Close();
|
||||
|
||||
// Find definition for current nodeType
|
||||
XmlNode def = createDef.SelectSingleNode("//nodeType [@alias = '" + nodeType + "']");
|
||||
var def = createDef.SelectSingleNode("//nodeType [@alias = '" + nodeType + "']");
|
||||
if (def == null)
|
||||
{
|
||||
throw new ArgumentException("The create dialog for \"" + nodeType + "\" does not match anything defined in the \"" + SystemFiles.CreateUiXml + "\". This could mean an incorrectly installed package or a corrupt UI file");
|
||||
@@ -46,7 +47,7 @@ namespace umbraco.cms.presentation
|
||||
try
|
||||
{
|
||||
//headerTitle.Text = title.Text;
|
||||
UI.Controls.Add(new UserControl().LoadControl(SystemDirectories.Umbraco + def.SelectSingleNode("./usercontrol").FirstChild.Value));
|
||||
UI.Controls.Add(LoadControl(SystemDirectories.Umbraco + def.SelectSingleNode("./usercontrol").FirstChild.Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -54,24 +55,6 @@ namespace umbraco.cms.presentation
|
||||
}
|
||||
}
|
||||
|
||||
#region Web Form Designer generated code
|
||||
override protected void OnInit(EventArgs e)
|
||||
{
|
||||
//
|
||||
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
|
||||
//
|
||||
InitializeComponent();
|
||||
base.OnInit(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Web.Security;
|
||||
using Umbraco.Core.Logging;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.BasePages;
|
||||
@@ -11,35 +12,19 @@ namespace umbraco
|
||||
{
|
||||
public class userTasks : interfaces.ITaskReturnUrl
|
||||
{
|
||||
|
||||
private string _alias;
|
||||
private int _parentID;
|
||||
private int _typeID;
|
||||
private int _userID;
|
||||
private string _returnUrl = "";
|
||||
|
||||
public int UserId
|
||||
{
|
||||
set { _userID = value; }
|
||||
}
|
||||
public int TypeID
|
||||
{
|
||||
set { _typeID = value; }
|
||||
get { return _typeID; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public int TypeID { get; set; }
|
||||
|
||||
public string Alias
|
||||
{
|
||||
set { _alias = value; }
|
||||
get { return _alias; }
|
||||
}
|
||||
|
||||
public int ParentID
|
||||
{
|
||||
set { _parentID = value; }
|
||||
get { return _parentID; }
|
||||
}
|
||||
public string Alias { get; set; }
|
||||
|
||||
public int ParentID { get; set; }
|
||||
|
||||
public string ReturnUrl
|
||||
{
|
||||
@@ -53,11 +38,11 @@ namespace umbraco
|
||||
//BusinessLogic.User.MakeNew(Alias, Alias, "", BusinessLogic.UserType.GetUserType(1));
|
||||
//return true;
|
||||
|
||||
MembershipCreateStatus status = MembershipCreateStatus.ProviderError;
|
||||
var status = MembershipCreateStatus.ProviderError;
|
||||
try
|
||||
{
|
||||
// Password is auto-generated. They are they required to change the password by editing the user information.
|
||||
MembershipUser u = Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].CreateUser(Alias,
|
||||
var u = Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].CreateUser(Alias,
|
||||
Membership.GeneratePassword(
|
||||
Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].MinRequiredPasswordLength,
|
||||
Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].MinRequiredNonAlphanumericCharacters),
|
||||
@@ -69,24 +54,16 @@ namespace umbraco
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Add(LogTypes.Error, ParentID, String.Format("Failed to create the user. Error from provider: {0}", status.ToString()));
|
||||
Log.Add(LogTypes.Debug, ParentID, ex.Message);
|
||||
LogHelper.Error<userTasks>(string.Format("Failed to create the user. Error from provider: {0}", status.ToString()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Delete()
|
||||
{
|
||||
BusinessLogic.User u = BusinessLogic.User.GetUser(ParentID);
|
||||
var u = User.GetUser(ParentID);
|
||||
u.disable();
|
||||
return true;
|
||||
}
|
||||
|
||||
public userTasks()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user