comparison Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs @ 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 1deccd6c3cb2
children b921a0ab8504
comparison
equal deleted inserted replaced
205:cfefc8a2ebc2 206:beeb06da4398
21 public ActionResult LogOn() 21 public ActionResult LogOn()
22 { 22 {
23 return View(); 23 return View();
24 } 24 }
25 25
26 public ActionResult TwitterLogOn() 26 public ActionResult TwitterLogOn(string returnUrl)
27 { 27 {
28 var oAuth = new OAuthTwitter(); 28 var oAuth = new OAuthTwitter();
29 29
30 if (Request["oauth_token"] == null) 30 if (Request["oauth_token"] == null)
31 { 31 {
32 var action = Url.Action("TwitterLogOn"); 32 var action = Url.Action("TwitterLogOn");
33 if (!string.IsNullOrWhiteSpace(returnUrl))
34 action += "?ReturnUrl=" + returnUrl;
35
33 var url = Request.Url.Scheme + "://" + Request.Url.Host + 36 var url = Request.Url.Scheme + "://" + Request.Url.Host +
34 (Request.Url.Port != 80 ? ":" + Request.Url.Port : string.Empty) + action; 37 (Request.Url.Port != 80 ? ":" + Request.Url.Port : string.Empty) + action;
35 38
36 return Redirect(oAuth.AuthorizationLinkGet(url).ToString()); 39 return Redirect(oAuth.AuthorizationLinkGet(url).ToString());
37 } 40 }
38 41
39 var response = oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]); 42 var response = oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]);
56 59
57 var personaService = AgendaFactory.GetPersonaService(); 60 var personaService = AgendaFactory.GetPersonaService();
58 personaService.CreateIfNotExist(IdentityProviderEnum.Twitter, username, nombre); 61 personaService.CreateIfNotExist(IdentityProviderEnum.Twitter, username, nombre);
59 62
60 _formsService.SignIn(Identification.Map[(int)IdentityProviderEnum.Twitter]+username, false); 63 _formsService.SignIn(Identification.Map[(int)IdentityProviderEnum.Twitter]+username, false);
64
65 if (!string.IsNullOrWhiteSpace(returnUrl))
66 return Redirect(returnUrl);
61 return RedirectToAction("Index", "Home"); 67 return RedirectToAction("Index", "Home");
62 } 68 }
63 69
64 ModelState.AddModelError("", "The user name or password provided is incorrect."); 70 ModelState.AddModelError("", "The user name or password provided is incorrect.");
65 71