diff 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
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs	Sat Jun 04 18:33:15 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs	Sat Jun 04 19:37:02 2011 -0300
@@ -38,22 +38,18 @@
         {
             if (ModelState.IsValid)
             {
-                if (MembershipService.ValidateUser(model.UserName, model.Password))
-                {
-                    FormsService.SignIn(model.UserName, model.RememberMe);
-                    if (Url.IsLocalUrl(returnUrl))
-                    {
-                        return Redirect(returnUrl);
-                    }
-                    else
-                    {
-                        return RedirectToAction("Index", "Home");
-                    }
-                }
-                else
-                {
-                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
-                }
+				if (MembershipService.ValidateUser(model.UserName, model.Password))
+				{
+					var personaService = AgendaFactory.GetPersonaService();
+					if (personaService.Validate(IdentityProviderEnum.BuiltIn, model.UserName))
+					{
+						FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.BuiltIn] + model.UserName, model.RememberMe);
+						if (Url.IsLocalUrl(returnUrl))
+							return Redirect(returnUrl);
+						return RedirectToAction("Index", "Home");
+					}
+				}
+            	ModelState.AddModelError("", "The user name or password provided is incorrect.");
             }
 
             // If we got this far, something failed, redisplay form
@@ -91,7 +87,7 @@
 					var personaService = AgendaFactory.GetPersonaService();
 					if (personaService.Validate(IdentityProviderEnum.Twitter, username, nombre))
 					{
-						FormsService.SignIn(username, false);
+						FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.Twitter]+username, false);
 						return RedirectToAction("Index", "Home");
 					}
 					ModelState.AddModelError("", "The user name or password provided is incorrect.");
@@ -155,13 +151,14 @@
 
                 if (createStatus == MembershipCreateStatus.Success)
                 {
-                    FormsService.SignIn(model.UserName, false /* createPersistentCookie */);
-                    return RedirectToAction("Index", "Home");
+					var personaService = AgendaFactory.GetPersonaService();
+					if (personaService.Validate(IdentityProviderEnum.BuiltIn, model.UserName, model.Nombre))
+					{
+						FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.BuiltIn] + model.UserName, false);
+						return RedirectToAction("Index", "Home");
+					}
                 }
-                else
-                {
-                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
-                }
+                ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
             }
 
             // If we got this far, something failed, redisplay form