From ceff51e65f62b56e9abf46ea591d43f8a915f703 Mon Sep 17 00:00:00 2001 From: Walance Date: Tue, 19 Nov 2013 10:06:34 +0100 Subject: [PATCH] Support for ReturnUrl on register page --- .../Modules/Orchard.Users/Controllers/AccountController.cs | 6 +++--- src/Orchard.Web/Modules/Orchard.Users/Views/LogOn.cshtml | 2 +- src/Orchard.Web/Modules/Orchard.Users/Views/Register.cshtml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs index df4ff22fa..bcce49bc5 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs +++ b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs @@ -122,7 +122,7 @@ namespace Orchard.Users.Controllers { [HttpPost] [AlwaysAccessible] [ValidateInput(false)] - public ActionResult Register(string userName, string email, string password, string confirmPassword) { + public ActionResult Register(string userName, string email, string password, string confirmPassword, string returnUrl = null) { // ensure users can register var registrationSettings = _orchardServices.WorkContext.CurrentSite.As(); if ( !registrationSettings.UsersCanRegister ) { @@ -154,7 +154,7 @@ namespace Orchard.Users.Controllers { } _authenticationService.SignIn(user, false /* createPersistentCookie */); - return Redirect("~/"); + return this.RedirectLocal(returnUrl); } ModelState.AddModelError("_FORM", T(ErrorCodeToString(/*createStatus*/MembershipCreateStatus.ProviderError))); @@ -198,7 +198,7 @@ namespace Orchard.Users.Controllers { _userService.SendLostPasswordEmail(username, nonce => Url.MakeAbsolute(Url.Action("LostPassword", "Account", new { Area = "Orchard.Users", nonce = nonce }), siteUrl)); _orchardServices.Notifier.Information(T("Check your e-mail for the confirmation link.")); - + return RedirectToAction("LogOn"); } diff --git a/src/Orchard.Web/Modules/Orchard.Users/Views/LogOn.cshtml b/src/Orchard.Web/Modules/Orchard.Users/Views/LogOn.cshtml index 03a64e6ab..6b0f6c15e 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Views/LogOn.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Users/Views/LogOn.cshtml @@ -8,7 +8,7 @@

@Html.TitleForPage((string)Model.Title)

@T("Please enter your username and password.") - @if(userCanRegister) { @Html.ActionLink(T("Register").Text, "Register") @T(" if you don't have an account.") } + @if(userCanRegister) { @Html.ActionLink(T("Register").Text, "Register", new { ReturnUrl = Request.QueryString["ReturnUrl"] }) @T(" if you don't have an account.") } @if(enableLostPassword) { @Html.ActionLink(T("Lost your Password?").Text, "RequestLostPassword") }

@Html.ValidationSummary(T("Login was unsuccessful. Please correct the errors and try again.").ToString()) diff --git a/src/Orchard.Web/Modules/Orchard.Users/Views/Register.cshtml b/src/Orchard.Web/Modules/Orchard.Users/Views/Register.cshtml index a349f1a0f..9a7a71eaf 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Views/Register.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Users/Views/Register.cshtml @@ -2,7 +2,7 @@

@T("Use the form below to create a new account.")

@T("Passwords are required to be a minimum of {0} characters in length.", ViewData["PasswordLength"])

@Html.ValidationSummary(T("Account creation was unsuccessful. Please correct the errors and try again.").ToString()) -@using (Html.BeginFormAntiForgeryPost()) { +@using (Html.BeginFormAntiForgeryPost(Url.Action("Register", new { ReturnUrl = Request.QueryString["ReturnUrl"] }))) {
@T("Account Information")