changeset 113:0eac9a1c1a6c

Soporte para asociar cuentas internas a un usuario ya identificado con twitter
author Carlos Peix
date Sat, 11 Jun 2011 12:44:47 -0300
parents 0bca45e1e664
children 1ce71844ffa4
files Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Agendas/trunk/src/Agendas.Web/Controllers/PerfilController.cs Agendas/trunk/src/Agendas.Web/Views/Perfil/AddBuiltInAccount.cshtml Agendas/trunk/src/Agendas.Web/Views/Perfil/Index.cshtml
diffstat 4 files changed, 80 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj	Sat Jun 11 01:20:59 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj	Sat Jun 11 12:44:47 2011 -0300
@@ -196,6 +196,9 @@
   <ItemGroup>
     <Content Include="Views\Perfil\Index.cshtml" />
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="Views\Perfil\AddBuiltInAccount.cshtml" />
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
--- a/Agendas/trunk/src/Agendas.Web/Controllers/PerfilController.cs	Sat Jun 11 01:20:59 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Controllers/PerfilController.cs	Sat Jun 11 12:44:47 2011 -0300
@@ -1,16 +1,29 @@
 using System;
 using System.Linq;
 using System.Web.Mvc;
+using System.Web.Routing;
 using AltNetHispano.Agendas.Domain;
 using AltNetHispano.Agendas.Factories;
 using AltNetHispano.Agendas.Twitter;
 using AltNetHispano.Agendas.Web.Models;
+using AltNetHispano.Agendas.Web.Services;
 
 namespace AltNetHispano.Agendas.Web.Controllers
 {
     public class PerfilController : Controller
     {
-        //
+		public IMembershipService MembershipService { get; set; }
+
+		protected override void Initialize(RequestContext requestContext)
+		{
+			//if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
+			if (MembershipService == null)
+				MembershipService = new AccountMembershipService();
+
+			base.Initialize(requestContext);
+		}
+
+		//
         // GET: /Perfil/
 
         public ActionResult Index()
@@ -63,6 +76,29 @@
 			return RedirectToAction("Index");
 		}
 
+		public ActionResult AddBuiltInAccount()
+		{
+			return View();
+		}
+
+		[HttpPost]
+		public ActionResult AddBuiltInAccount(LogOnModel model)
+		{
+			if (ModelState.IsValid)
+			{
+				if (MembershipService.ValidateUser(model.UserName, model.Password))
+				{
+					var personaService = AgendaFactory.GetPersonaService();
+					personaService.AddCuenta(IdentityProviderEnum.BuiltIn, model.UserName);
+					RedirectToAction("Index");
+				}
+				ModelState.AddModelError("", "The user name or password provided is incorrect.");
+			}
+
+			// If we got this far, something failed, redisplay form
+			return View(model);
+		}
+
 		public ActionResult Remove(string identityProvider, string username)
 		{
 			var personaService = AgendaFactory.GetPersonaService();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Web/Views/Perfil/AddBuiltInAccount.cshtml	Sat Jun 11 12:44:47 2011 -0300
@@ -0,0 +1,38 @@
+@model AltNetHispano.Agendas.Web.Models.LogOnModel
+<h2>Perfil</h2>
+<p>
+    Hola estas son tus cuentas registradas
+</p>
+@Html.ValidationSummary(true, "La validación no fue exitosa, por favor intente de nuevo")
+
+@using (Html.BeginForm()) {
+    <div>
+        <fieldset>
+            <legend>Información de la cuenta interna</legend>
+
+            <div class="editor-label">
+                @Html.LabelFor(m => m.UserName)
+            </div>
+            <div class="editor-field">
+                @Html.TextBoxFor(m => m.UserName)
+                @Html.ValidationMessageFor(m => m.UserName)
+            </div>
+
+            <div class="editor-label">
+                @Html.LabelFor(m => m.Password)
+            </div>
+            <div class="editor-field">
+                @Html.PasswordFor(m => m.Password)
+                @Html.ValidationMessageFor(m => m.Password)
+            </div>
+
+            <p>
+                <input type="submit" value="Validar" />
+            </p>
+        </fieldset>
+    </div>
+}
+
+<p>
+@Html.ActionLink("Volver", "Index")
+</p>
--- a/Agendas/trunk/src/Agendas.Web/Views/Perfil/Index.cshtml	Sat Jun 11 01:20:59 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Views/Perfil/Index.cshtml	Sat Jun 11 12:44:47 2011 -0300
@@ -27,4 +27,6 @@
 
 <p>
 @Html.ActionLink("Asociar cuenta de Twitter", "AddTwitterAccount")
+<br/>
+@Html.ActionLink("Asociar cuenta interna", "AddBuiltInAccount")
 </p>