comparison Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs @ 96:1eb5a0e531bf

Funcionamiento con cuenta interna y con cuenta de twitter, falta unificar usuarios Estructura de aspnetdb dentro de base de datos de altnet hispano, se debe ejecutar: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe para crear dicha estructura, de todas formas el objetivo seria tener una tabla de usuario y password interna, no parecería ser necesaria toda la estructura de aspnetdb
author Nelo@Kenia.neluz.int
date Sat, 04 Jun 2011 19:37:02 -0300
parents db4b1e2cae49
children 1ee5711256db
comparison
equal deleted inserted replaced
95:83d76f6e0a3c 96:1eb5a0e531bf
36 [HttpPost] 36 [HttpPost]
37 public ActionResult LogOn(LogOnModel model, string returnUrl) 37 public ActionResult LogOn(LogOnModel model, string returnUrl)
38 { 38 {
39 if (ModelState.IsValid) 39 if (ModelState.IsValid)
40 { 40 {
41 if (MembershipService.ValidateUser(model.UserName, model.Password)) 41 if (MembershipService.ValidateUser(model.UserName, model.Password))
42 { 42 {
43 FormsService.SignIn(model.UserName, model.RememberMe); 43 var personaService = AgendaFactory.GetPersonaService();
44 if (Url.IsLocalUrl(returnUrl)) 44 if (personaService.Validate(IdentityProviderEnum.BuiltIn, model.UserName))
45 { 45 {
46 return Redirect(returnUrl); 46 FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.BuiltIn] + model.UserName, model.RememberMe);
47 } 47 if (Url.IsLocalUrl(returnUrl))
48 else 48 return Redirect(returnUrl);
49 { 49 return RedirectToAction("Index", "Home");
50 return RedirectToAction("Index", "Home"); 50 }
51 } 51 }
52 } 52 ModelState.AddModelError("", "The user name or password provided is incorrect.");
53 else
54 {
55 ModelState.AddModelError("", "The user name or password provided is incorrect.");
56 }
57 } 53 }
58 54
59 // If we got this far, something failed, redisplay form 55 // If we got this far, something failed, redisplay form
60 return View(model); 56 return View(model);
61 } 57 }
89 var nombre = GetXmlContent(xml, "name"); 85 var nombre = GetXmlContent(xml, "name");
90 86
91 var personaService = AgendaFactory.GetPersonaService(); 87 var personaService = AgendaFactory.GetPersonaService();
92 if (personaService.Validate(IdentityProviderEnum.Twitter, username, nombre)) 88 if (personaService.Validate(IdentityProviderEnum.Twitter, username, nombre))
93 { 89 {
94 FormsService.SignIn(username, false); 90 FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.Twitter]+username, false);
95 return RedirectToAction("Index", "Home"); 91 return RedirectToAction("Index", "Home");
96 } 92 }
97 ModelState.AddModelError("", "The user name or password provided is incorrect."); 93 ModelState.AddModelError("", "The user name or password provided is incorrect.");
98 94
99 95
153 // Attempt to register the user 149 // Attempt to register the user
154 MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email); 150 MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);
155 151
156 if (createStatus == MembershipCreateStatus.Success) 152 if (createStatus == MembershipCreateStatus.Success)
157 { 153 {
158 FormsService.SignIn(model.UserName, false /* createPersistentCookie */); 154 var personaService = AgendaFactory.GetPersonaService();
159 return RedirectToAction("Index", "Home"); 155 if (personaService.Validate(IdentityProviderEnum.BuiltIn, model.UserName, model.Nombre))
156 {
157 FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.BuiltIn] + model.UserName, false);
158 return RedirectToAction("Index", "Home");
159 }
160 } 160 }
161 else 161 ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
162 {
163 ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
164 }
165 } 162 }
166 163
167 // If we got this far, something failed, redisplay form 164 // If we got this far, something failed, redisplay form
168 ViewBag.PasswordLength = MembershipService.MinPasswordLength; 165 ViewBag.PasswordLength = MembershipService.MinPasswordLength;
169 return View(model); 166 return View(model);