comparison Agendas/trunk/src/Agendas.Web/Controllers/PerfilController.cs @ 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
comparison
equal deleted inserted replaced
112:0bca45e1e664 113:0eac9a1c1a6c
1 using System; 1 using System;
2 using System.Linq; 2 using System.Linq;
3 using System.Web.Mvc; 3 using System.Web.Mvc;
4 using System.Web.Routing;
4 using AltNetHispano.Agendas.Domain; 5 using AltNetHispano.Agendas.Domain;
5 using AltNetHispano.Agendas.Factories; 6 using AltNetHispano.Agendas.Factories;
6 using AltNetHispano.Agendas.Twitter; 7 using AltNetHispano.Agendas.Twitter;
7 using AltNetHispano.Agendas.Web.Models; 8 using AltNetHispano.Agendas.Web.Models;
9 using AltNetHispano.Agendas.Web.Services;
8 10
9 namespace AltNetHispano.Agendas.Web.Controllers 11 namespace AltNetHispano.Agendas.Web.Controllers
10 { 12 {
11 public class PerfilController : Controller 13 public class PerfilController : Controller
12 { 14 {
13 // 15 public IMembershipService MembershipService { get; set; }
16
17 protected override void Initialize(RequestContext requestContext)
18 {
19 //if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
20 if (MembershipService == null)
21 MembershipService = new AccountMembershipService();
22
23 base.Initialize(requestContext);
24 }
25
26 //
14 // GET: /Perfil/ 27 // GET: /Perfil/
15 28
16 public ActionResult Index() 29 public ActionResult Index()
17 { 30 {
18 var persona = IdentityContext.GetUsuario(); 31 var persona = IdentityContext.GetUsuario();
61 } 74 }
62 } 75 }
63 return RedirectToAction("Index"); 76 return RedirectToAction("Index");
64 } 77 }
65 78
79 public ActionResult AddBuiltInAccount()
80 {
81 return View();
82 }
83
84 [HttpPost]
85 public ActionResult AddBuiltInAccount(LogOnModel model)
86 {
87 if (ModelState.IsValid)
88 {
89 if (MembershipService.ValidateUser(model.UserName, model.Password))
90 {
91 var personaService = AgendaFactory.GetPersonaService();
92 personaService.AddCuenta(IdentityProviderEnum.BuiltIn, model.UserName);
93 RedirectToAction("Index");
94 }
95 ModelState.AddModelError("", "The user name or password provided is incorrect.");
96 }
97
98 // If we got this far, something failed, redisplay form
99 return View(model);
100 }
101
66 public ActionResult Remove(string identityProvider, string username) 102 public ActionResult Remove(string identityProvider, string username)
67 { 103 {
68 var personaService = AgendaFactory.GetPersonaService(); 104 var personaService = AgendaFactory.GetPersonaService();
69 105
70 IdentityProviderEnum ip; 106 IdentityProviderEnum ip;