Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs @ 94:db4b1e2cae49
Cambio del nombre de la clase Ponente a Persona
Se agrega la clase Cuenta para identificar cada una de las cuentas con que se puede autenticar una persona
Alta Automatica de cuentas de twitter creando la persona
author | Nelo@Kenia.neluz.int |
---|---|
date | Sat, 04 Jun 2011 12:11:17 -0300 |
parents | 65f0b3d70c18 |
children | 1eb5a0e531bf |
comparison
equal
deleted
inserted
replaced
93:65f0b3d70c18 | 94:db4b1e2cae49 |
---|---|
1 using System; | 1 using System; |
2 using System.Web.Mvc; | 2 using System.Web.Mvc; |
3 using System.Web.Routing; | 3 using System.Web.Routing; |
4 using System.Web.Security; | 4 using System.Web.Security; |
5 using AltNetHispano.Agendas.Domain; | |
6 using AltNetHispano.Agendas.Factories; | |
5 using AltNetHispano.Agendas.Twitter; | 7 using AltNetHispano.Agendas.Twitter; |
6 using AltNetHispano.Agendas.Web.Models; | 8 using AltNetHispano.Agendas.Web.Models; |
7 using AltNetHispano.Agendas.Web.Services; | 9 using AltNetHispano.Agendas.Web.Services; |
8 | 10 |
9 namespace AltNetHispano.Agendas.Web.Controllers | 11 namespace AltNetHispano.Agendas.Web.Controllers |
58 return View(model); | 60 return View(model); |
59 } | 61 } |
60 | 62 |
61 public ActionResult TwitterLogOn() | 63 public ActionResult TwitterLogOn() |
62 { | 64 { |
63 var oAuth = new oAuthTwitter(); | 65 var oAuth = new OAuthTwitter(); |
64 | 66 |
65 if (Request["oauth_token"] == null) | 67 if (Request["oauth_token"] == null) |
66 { | 68 { |
67 //Redirect the user to Twitter for authorization. | 69 //Redirect the user to Twitter for authorization. |
68 //Using oauth_callback for local testing. | 70 //Using oauth_callback for local testing. |
79 oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]); | 81 oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]); |
80 if (oAuth.TokenSecret.Length > 0) | 82 if (oAuth.TokenSecret.Length > 0) |
81 { | 83 { |
82 //We now have the credentials, so make a call to the Twitter API. | 84 //We now have the credentials, so make a call to the Twitter API. |
83 const string url = "http://twitter.com/account/verify_credentials.xml"; | 85 const string url = "http://twitter.com/account/verify_credentials.xml"; |
84 string xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty); | 86 string xml = oAuth.OAuthWebRequest(OAuthTwitter.Method.GET, url, String.Empty); |
85 | 87 |
86 var username = GetXmlContent(xml, "screen_name"); | 88 var username = GetXmlContent(xml, "screen_name"); |
87 //TODO: Validar que este usuario de twitter corresponde a un usuario del sitio | 89 var nombre = GetXmlContent(xml, "name"); |
88 | 90 |
89 FormsService.SignIn(username, false); | 91 var personaService = AgendaFactory.GetPersonaService(); |
90 return RedirectToAction("Index", "Home"); | 92 if (personaService.Validate(IdentityProviderEnum.Twitter, username, nombre)) |
93 { | |
94 FormsService.SignIn(username, false); | |
95 return RedirectToAction("Index", "Home"); | |
96 } | |
97 ModelState.AddModelError("", "The user name or password provided is incorrect."); | |
98 | |
91 | 99 |
92 //POST Test | 100 //POST Test |
93 //url = "http://twitter.com/statuses/update.xml"; | 101 //url = "http://twitter.com/statuses/update.xml"; |
94 //xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, url, "status=" + oAuth.UrlEncode("Hello @swhitley - Testing the .NET oAuth API")); | 102 //xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, url, "status=" + oAuth.UrlEncode("Hello @swhitley - Testing the .NET oAuth API")); |
95 //apiResponse.InnerHtml = Server.HtmlEncode(xml); | 103 //apiResponse.InnerHtml = Server.HtmlEncode(xml); |