From 6db14b96d8fa5b1380da8ad3d25b032c533ee77f Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Sun, 5 Jan 2014 14:21:50 +0100 Subject: [PATCH] Update the signup to eliminate a weird error where you could not sign up with a single name (no last name) that already existed as a name.. Also removed the ErrorMessage.dll that had a single Hiccup.cs in it, recreated the Hiccup class elsewhere. --- OurUmbraco.Site/OurUmbraco.Site.csproj | 5 +- .../usercontrols/our.umbraco.org/Signup.ascx | 4 + dependencies/Our/ErrorMessage.dll | Bin 4608 -> 0 bytes our.umbraco.org/Hiccup.cs | 23 ++++++ our.umbraco.org/our.umbraco.org.csproj | 7 +- our.umbraco.org/usercontrols/Signup.ascx | 4 + our.umbraco.org/usercontrols/Signup.ascx.cs | 73 +++++++++++++----- .../usercontrols/Signup.ascx.designer.cs | 9 +++ 8 files changed, 99 insertions(+), 26 deletions(-) delete mode 100644 dependencies/Our/ErrorMessage.dll create mode 100644 our.umbraco.org/Hiccup.cs diff --git a/OurUmbraco.Site/OurUmbraco.Site.csproj b/OurUmbraco.Site/OurUmbraco.Site.csproj index 875fa972..76b3f9ad 100644 --- a/OurUmbraco.Site/OurUmbraco.Site.csproj +++ b/OurUmbraco.Site/OurUmbraco.Site.csproj @@ -70,9 +70,6 @@ ..\dependencies\Our\Elmah.dll - - ..\dependencies\Our\ErrorMessage.dll - False ..\dependencies\4.9.1\Examine.dll @@ -396,6 +393,7 @@ + @@ -972,7 +970,6 @@ - diff --git a/OurUmbraco.Site/usercontrols/our.umbraco.org/Signup.ascx b/OurUmbraco.Site/usercontrols/our.umbraco.org/Signup.ascx index 19e6c1aa..e636434c 100644 --- a/OurUmbraco.Site/usercontrols/our.umbraco.org/Signup.ascx +++ b/OurUmbraco.Site/usercontrols/our.umbraco.org/Signup.ascx @@ -1,6 +1,10 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Signup.ascx.cs" Inherits="our.usercontrols.Signup" %> + +

There is already an account with this e-mail address! You can login or reset your password.

+
+
diff --git a/dependencies/Our/ErrorMessage.dll b/dependencies/Our/ErrorMessage.dll deleted file mode 100644 index 4ba9df402b0ae5736c91179913f30f40ada5dacf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4608 zcmeHKU2Ggz75-*+?buGUjh!Z>NtKS{L^vhctm7^DA<(tGo7iAGu6OM;VC2m1-dzu! zo!Q)(P2)rYBMMT55U72qc;ZJwYK26DREZK%gx~@7A)*rE4T%VzDX&nWhVS0l^{%~1 zg?K=f;I8MJdw%YjbI$!cp8NcF5CahBbN@c@7T>C6G=4a2P@H)3P6BWC-yMF-n7un( zSaSlaF8!*sYgWnjJU_IG!jcWoay%=0DR0&MvPkaQHE^V9dLakQ8ZkVZJvQI^+C7-V zJB>bIfSlfl`@tyR7M~0s1r}ds`F8eUr0vN$&>mxnANdd`F+z3g>`w5ikSet&6(#-;{CS@Q?q_l4t zcGN^EhdNq@-Y2DSeJX0vRSK0YhThpSz+@+_`u7-@YRWegJ@|#iZ|wjK#rzN2o>UCa zaU91F!W1HYow#BVW-JG6C7Vd z8bj6XFi~yIRx@x?cRP6ln0o*(ngcC3Kj)VluJ{acQu=aE1c6-@$+GKW+9{P9^(}nl z*Mm^hl9xrXqnlis!2(C27L(3J0m(su*QI-!uZ zi_i&O(IVD_T^4c-(R&;`-6tv)Q3{bPg}y`}Jjx+jb{897=+s1VS;)ZgJ#IS`Y*`iI z1zr#01z$ct5pp*c8)18hsJJvpZA=7#s1@Dyf^wm)*kWfzP?Anvsdft)N5!c&r2Q~) zt!{hk-QyM{C!iE|3#R<~x^${*4-ge3vr@A=gK7CV)o{ax>~Ow0Wv#@_c+9e2&kK3o zDTx46er?$aoMLCZ7aLBw+n;7iy9E~CHB0>0F)0Wv91f=oBvs*S?{9LEEKflxiGBMaOl*j+9S_VSQ0tYlt8Om&9tTza$+^ zFG*Lwr|B@FLmP{t?%E~6g%++BqWcq%t|8>F&hzx7+H*Y2uKnia7pLy-ocPh{_rG^) zP)Pv3i~*D{SKhWcZ@L%U)YjJRbO2?b^kVQ@xu`{EXc zmK0o}N}|Uy6NyA@hmp8w;6QRdSJ+&|$D0ZNw7P%{6cUeZin2~Xm)GaH-gm1p)~3Wt z4;px+bEEUh(kF4kK>wUml78S({San=+{<_z2YWD7P~m6v23A-z z8JOkxsvfPPt}|YhwJOxv%RS!3vsgn}j9_~nEY@x*jPa-1toH9x)0UbA%Myry+tw~pPO-R-$OqsL6>8Dg=;mEkfg7FXrgS=l~L Y2mVn4tNA~p{-5ci + + ASPXCodeBehind + @@ -278,7 +281,9 @@ - + + ASPXCodeBehind + diff --git a/our.umbraco.org/usercontrols/Signup.ascx b/our.umbraco.org/usercontrols/Signup.ascx index 19e6c1aa..e636434c 100644 --- a/our.umbraco.org/usercontrols/Signup.ascx +++ b/our.umbraco.org/usercontrols/Signup.ascx @@ -1,6 +1,10 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Signup.ascx.cs" Inherits="our.usercontrols.Signup" %> + +

There is already an account with this e-mail address! You can login or reset your password.

+
+
diff --git a/our.umbraco.org/usercontrols/Signup.ascx.cs b/our.umbraco.org/usercontrols/Signup.ascx.cs index fbb7abc6..d672f5eb 100644 --- a/our.umbraco.org/usercontrols/Signup.ascx.cs +++ b/our.umbraco.org/usercontrols/Signup.ascx.cs @@ -3,10 +3,16 @@ using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; +using System.Xml; +using our.Rest; +using umbraco; +using umbraco.BusinessLogic; using umbraco.cms.businesslogic.member; -namespace our.usercontrols { - public partial class Signup : System.Web.UI.UserControl { +namespace our.usercontrols +{ + public partial class Signup : System.Web.UI.UserControl + { public string Group { get; set; } public string memberType { get; set; } @@ -14,11 +20,15 @@ namespace our.usercontrols { private Member m = umbraco.cms.businesslogic.member.Member.GetCurrentMember(); - protected void Page_Load(object sender, EventArgs e) { + protected void Page_Load(object sender, EventArgs e) + { //lazyloading the needed javascript for validation. (addded it to the master template as our ahah forms need it aswel) //umbraco.library.RegisterJavaScriptFile("jquery.validation", "/scripts/jquery.validation.js"); - if (!Page.IsPostBack && m != null) { + MemberExists.Visible = false; + + if (!Page.IsPostBack && m != null) + { tb_name.Text = m.Text; tb_email.Text = m.Email; @@ -30,7 +40,8 @@ namespace our.usercontrols { //treshold and newsletter - if (m.getProperty("bugMeNot") != null) { + if (m.getProperty("bugMeNot") != null) + { int c = 0; int.TryParse(m.getProperty("bugMeNot").Value.ToString(), out c); @@ -54,10 +65,12 @@ namespace our.usercontrols { } - protected void createMember(object sender, EventArgs e) { + protected void createMember(object sender, EventArgs e) + { //Member is already logged in, and we just need to save his new data... - if (m != null) { + if (m != null) + { m.Text = tb_name.Text; m.Email = tb_email.Text; m.LoginName = tb_email.Text; @@ -84,7 +97,7 @@ namespace our.usercontrols { m.XmlGenerate(new System.Xml.XmlDocument()); m.Save(); - + //Refresh the member cache data @@ -93,16 +106,28 @@ namespace our.usercontrols { Response.Redirect(umbraco.library.NiceUrl(NextPage)); - } else { - if (tb_email.Text != "") { - m = Member.GetMemberFromEmail(tb_email.Text); - if (m == null) { + } + else + { + if (tb_email.Text != "") + { + m = Member.GetMemberFromLoginName(tb_email.Text); + if (m == null) + { MemberType mt = MemberType.GetByAlias(memberType); - m = Member.MakeNew(tb_name.Text, mt, new umbraco.BusinessLogic.User(0)); + + // Adding " Temp" is a hack - bizarrely, when you create a member using MakeNew and + // the name does not have a space in it (like: Ben) you'll get a YSOD saying the + // username already exists. However, create it with a space in it and everything is + // fine and dandy! So now we just force the last name to be "Temp" during creation + // and then update the member's name immediately after that... -SJ + m = Member.MakeNew(tb_name.Text + " Temp", mt, new User(0)); + m.Text = tb_name.Text; + m.Email = tb_email.Text; m.Password = tb_password.Text; m.LoginName = tb_email.Text; - + //Location m.getProperty("location").Value = tb_location.Text; m.getProperty("latitude").Value = tb_lat.Value; @@ -113,32 +138,38 @@ namespace our.usercontrols { m.getProperty("flickr").Value = tb_flickr.Text; m.getProperty("company").Value = tb_company.Text; m.getProperty("profileText").Value = tb_bio.Text; - + //treshold + newsletter m.getProperty("treshold").Value = tb_treshold.Text; m.getProperty("bugMeNot").Value = cb_bugMeNot.Checked; - + //Standard values m.getProperty("reputationTotal").Value = 20; m.getProperty("reputationCurrent").Value = 20; m.getProperty("forumPosts").Value = 0; - - if (!string.IsNullOrEmpty(Group)) { + + if (!string.IsNullOrEmpty(Group)) + { MemberGroup mg = MemberGroup.GetByName(Group); if (mg != null) m.AddGroup(mg.Id); } //set a default avatar - Rest.BuddyIcon.SetAvatar(m.Id, "gravatar"); + BuddyIcon.SetAvatar(m.Id, "gravatar"); m.Save(); - m.XmlGenerate(new System.Xml.XmlDocument()); + m.XmlGenerate(new XmlDocument()); Member.AddMemberToCache(m); - Response.Redirect(umbraco.library.NiceUrl(NextPage)); + Response.Redirect(library.NiceUrl(NextPage)); + } + else + { + MemberExists.Visible = true; + Panel1.Visible = false; } } } diff --git a/our.umbraco.org/usercontrols/Signup.ascx.designer.cs b/our.umbraco.org/usercontrols/Signup.ascx.designer.cs index d6b3754e..889a5ac8 100644 --- a/our.umbraco.org/usercontrols/Signup.ascx.designer.cs +++ b/our.umbraco.org/usercontrols/Signup.ascx.designer.cs @@ -12,6 +12,15 @@ namespace our.usercontrols { public partial class Signup { + /// + /// MemberExists control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel MemberExists; + /// /// Panel1 control. ///