comparison Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs @ 112:0bca45e1e664

Pantalla de Perfil donde se puede asociar la cuenta de twitter al usuario existente
author Nelo@Kenia.neluz.int
date Sat, 11 Jun 2011 01:20:59 -0300
parents 1ee5711256db
children 7a2eeb9e9bf9
comparison
equal deleted inserted replaced
111:90ce239cfa6d 112:0bca45e1e664
71 else 71 else
72 { 72 {
73 var response = oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]); 73 var response = oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]);
74 if (response.Length > 0) 74 if (response.Length > 0)
75 { 75 {
76 var username = GetResponseContent(response, "screen_name"); 76 var username = OAuthTwitter.GetResponseContent(response, "screen_name");
77 var nombre = GetResponseContent(response, "name"); 77 var nombre = OAuthTwitter.GetResponseContent(response, "name");
78 78
79 var personaService = AgendaFactory.GetPersonaService(); 79 var personaService = AgendaFactory.GetPersonaService();
80 if (personaService.Validate(IdentityProviderEnum.Twitter, username, nombre)) 80 if (personaService.Validate(IdentityProviderEnum.Twitter, username, nombre))
81 { 81 {
82 FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.Twitter]+username, false); 82 FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.Twitter]+username, false);
85 ModelState.AddModelError("", "The user name or password provided is incorrect."); 85 ModelState.AddModelError("", "The user name or password provided is incorrect.");
86 } 86 }
87 } 87 }
88 88
89 return RedirectToAction("LogOn"); 89 return RedirectToAction("LogOn");
90 }
91
92 private static string GetResponseContent(string response, string tagName)
93 {
94 var tagStart = "\"" + tagName + "\":";
95 var tagEnd = ",";
96
97 var start = response.IndexOf(tagStart) + tagStart.Length;
98 if (start > tagStart.Length)
99 {
100 var end = response.IndexOf(tagEnd, start);
101 if (end > 0)
102 {
103 return response.Substring(start + 1, end - start - 2);
104 }
105 }
106 return string.Empty;
107 } 90 }
108 91
109 // ************************************** 92 // **************************************
110 // URL: /Account/LogOff 93 // URL: /Account/LogOff
111 // ************************************** 94 // **************************************