From 19a50ce4908c18cea47e6e51190a4fcaef0b8996 Mon Sep 17 00:00:00 2001 From: Samantha Webb Date: Thu, 26 Jan 2012 15:58:58 -0500 Subject: [PATCH 1/3] fix incorrect UserId argument passed --- Source/VidPub.Web/Controllers/AccountController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/VidPub.Web/Controllers/AccountController.cs b/Source/VidPub.Web/Controllers/AccountController.cs index 5e5871c..bf70b4a 100644 --- a/Source/VidPub.Web/Controllers/AccountController.cs +++ b/Source/VidPub.Web/Controllers/AccountController.cs @@ -64,7 +64,7 @@ public ActionResult Register(string Email, string Password, string Confirm) { var result = _users.Register(Email, Password, Confirm); if (result.Success) { - SetToken(result.UserID); + SetToken(result.UserID.ID); return RedirectToAction("Index", "Home"); } else { ViewBag.Message = result.Message; From 046fca76ce0d4f5135742161640c55325975265d Mon Sep 17 00:00:00 2001 From: Samantha Webb Date: Thu, 26 Jan 2012 17:25:34 -0500 Subject: [PATCH 2/3] allow SQL Server exception to be caught as well --- Source/VidPub.Web/Model/Users.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/VidPub.Web/Model/Users.cs b/Source/VidPub.Web/Model/Users.cs index 6ce4b19..041ab43 100644 --- a/Source/VidPub.Web/Model/Users.cs +++ b/Source/VidPub.Web/Model/Users.cs @@ -1,5 +1,6 @@ using System; -using System.Collections.Generic; +using System.Collections.Generic; +using System.Data.SqlClient; using System.Linq; using System.Text; using System.Dynamic; @@ -20,7 +21,9 @@ public dynamic Register(string email, string password, string confirm) { result.UserID = this.Insert(new { Email = email, HashedPassword = Hash(password) }); result.Success = true; result.Message = "Thanks for signing up!"; - } catch (SqlCeException ex) { + } catch (Exception ex) + { + if (ex is SqlCeException || ex is SqlException) result.Message = "This email already exists in our system"; } } else { From 06d66fe6d217bced2611b7677c836d84d47ecce2 Mon Sep 17 00:00:00 2001 From: Samantha Webb Date: Thu, 26 Jan 2012 17:36:34 -0500 Subject: [PATCH 3/3] put a unique constraint on email in the Users table --- Source/VidPub.Web/App_Data/DBScripts.sql | Bin 30758 -> 31410 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Source/VidPub.Web/App_Data/DBScripts.sql b/Source/VidPub.Web/App_Data/DBScripts.sql index 10bcba6a90effb907461f96d3c0fa8023999f9d7..af9bcdac44e017809008260cc36fe158c42c2e81 100644 GIT binary patch delta 167 zcmZ4XfpODU#tmu}lM4itG(8#e7*ZHg87deQ7@`?M83GyNfn+gIqzFjHGq^J3G9)r& zGUQAwR97}+&}T4WFawhY42D3q0+2LkuwpOIr4=WAFr8 g6$&(70m$}e@SEJosXX}vBj4s}EDDU159o6M0ME1{oB#j- delta 9 Qcmdn=m2uez#tmu}02yWkjsO4v