From 26d34da16a89e69b3298e01bb1f9da2b71fe3fdc Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Fri, 5 Nov 2010 15:18:26 -0700 Subject: [PATCH] Fixing user registration to not sign the user in after account creation if new user accounts must be approved before use. via the "Users must be approved before they can log in" site setting --HG-- branch : dev --- .../Orchard.Users/Controllers/AccountController.cs | 8 ++++++++ .../Modules/Orchard.Users/Orchard.Users.csproj | 1 + .../Views/Account/RegistrationPending.cshtml | 3 +++ .../Parts/Users.RegistrationSettings.cshtml | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/Orchard.Web/Modules/Orchard.Users/Views/Account/RegistrationPending.cshtml diff --git a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs index beb07096a..490b6695b 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs +++ b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs @@ -125,6 +125,10 @@ namespace Orchard.Users.Controllers { return RedirectToAction("ChallengeEmailSent"); } + if (user.As().RegistrationStatus == UserStatus.Pending) { + return RedirectToAction("RegistrationPending"); + } + _authenticationService.SignIn(user, false /* createPersistentCookie */); return Redirect("~/"); } @@ -174,6 +178,10 @@ namespace Orchard.Users.Controllers { } } + public ActionResult RegistrationPending() { + return View(); + } + public ActionResult ChangePasswordSuccess() { return View(); } diff --git a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj index c08223b12..0e6484899 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj +++ b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj @@ -128,6 +128,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Users/Views/Account/RegistrationPending.cshtml b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/RegistrationPending.cshtml new file mode 100644 index 000000000..cb4755646 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/RegistrationPending.cshtml @@ -0,0 +1,3 @@ +@model dynamic +

@Html.TitleForPage(T("User Registration Pending").ToString())

+

@T("Your user account has been created but has to be approved before it can be used.")

diff --git a/src/Orchard.Web/Modules/Orchard.Users/Views/EditorTemplates/Parts/Users.RegistrationSettings.cshtml b/src/Orchard.Web/Modules/Orchard.Users/Views/EditorTemplates/Parts/Users.RegistrationSettings.cshtml index b34c9c324..c839341bf 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Views/EditorTemplates/Parts/Users.RegistrationSettings.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Users/Views/EditorTemplates/Parts/Users.RegistrationSettings.cshtml @@ -9,7 +9,7 @@
@Html.EditorFor(m => m.UsersMustValidateEmail) - + @Html.ValidationMessage("UsersMustValidateEmail", "*")