changeset 206:beeb06da4398

Al querés ingresar a un lugar que requiere autenticación y luego de autenticarse, vuelve a la página donde quería entrar
author nelopauselli
date Wed, 24 Aug 2011 10:38:13 -0300
parents cfefc8a2ebc2
children beeb7fd09ae7
files Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs Agendas/trunk/src/Agendas.Web/Views/Account/LogOn.cshtml
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs	Wed Aug 24 10:19:48 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs	Wed Aug 24 10:38:13 2011 -0300
@@ -23,15 +23,18 @@
             return View();
         }
 
-		public ActionResult TwitterLogOn()
+		public ActionResult TwitterLogOn(string returnUrl)
 		{
 			var oAuth = new OAuthTwitter();
 
 			if (Request["oauth_token"] == null)
 			{
 				var action = Url.Action("TwitterLogOn");
+				if (!string.IsNullOrWhiteSpace(returnUrl))
+					action += "?ReturnUrl=" + returnUrl;
+
 				var url = Request.Url.Scheme + "://" + Request.Url.Host +
-				          (Request.Url.Port != 80 ? ":" + Request.Url.Port : string.Empty) + action;
+						  (Request.Url.Port != 80 ? ":" + Request.Url.Port : string.Empty) + action;
 
 				return Redirect(oAuth.AuthorizationLinkGet(url).ToString());
 			}
@@ -58,6 +61,9 @@
 				personaService.CreateIfNotExist(IdentityProviderEnum.Twitter, username, nombre);
 
 				_formsService.SignIn(Identification.Map[(int)IdentityProviderEnum.Twitter]+username, false);
+
+				if (!string.IsNullOrWhiteSpace(returnUrl))
+					return Redirect(returnUrl);
 				return RedirectToAction("Index", "Home");
 			}
 
--- a/Agendas/trunk/src/Agendas.Web/Views/Account/LogOn.cshtml	Wed Aug 24 10:19:48 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Views/Account/LogOn.cshtml	Wed Aug 24 10:38:13 2011 -0300
@@ -12,7 +12,7 @@
         <br />
         <table border="0">
             <tr>
-                <td><a href="@Url.Action("TwitterLogOn")"><img src="@Url.Content("~/Content/twitter/sign-in-with-twitter-d.png")" alt="Sign in with twitter" /></a></td>
+                <td><a href="@Url.Action("TwitterLogOn", new {returnUrl = Request["ReturnUrl"]})"><img src="@Url.Content("~/Content/twitter/sign-in-with-twitter-d.png")" alt="Sign in with twitter" /></a></td>
                 <td>Identifíquese utilizando su cuenta de twitter</td>
             </tr>
         </table>