comparison Agendas/trunk/src/Agendas.Web/Controllers/PerfilController.cs @ 142:62dc9fb3a03e

Quitando cuentas BuiltIn
author Nelo@Guinea.neluz.int
date Mon, 01 Aug 2011 00:28:04 -0300
parents 7a2eeb9e9bf9
children 97e51ddeeb58
comparison
equal deleted inserted replaced
141:a5ff4de4a1d3 142:62dc9fb3a03e
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;
5 using AltNetHispano.Agendas.Domain; 4 using AltNetHispano.Agendas.Domain;
6 using AltNetHispano.Agendas.Factories; 5 using AltNetHispano.Agendas.Factories;
7 using AltNetHispano.Agendas.Twitter; 6 using AltNetHispano.Agendas.Twitter;
8 using AltNetHispano.Agendas.Web.Models; 7 using AltNetHispano.Agendas.Web.Models;
9 using AltNetHispano.Agendas.Web.Services;
10 8
11 namespace AltNetHispano.Agendas.Web.Controllers 9 namespace AltNetHispano.Agendas.Web.Controllers
12 { 10 {
13 public class PerfilController : Controller 11 public class PerfilController : Controller
14 { 12 {
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 //
27 // GET: /Perfil/
28
29 public ActionResult Index() 13 public ActionResult Index()
30 { 14 {
31 var persona = IdentityContext.GetUsuario(); 15 var persona = IdentityContext.GetUsuario();
32 16
33 if (persona == null) 17 if (persona == null)
46 }; 30 };
47 31
48 return View(model); 32 return View(model);
49 } 33 }
50 34
51 public ActionResult AddTwitterAccount() 35 public ActionResult AddGoogleAccount()
36 {
37 throw new NotImplementedException();
38 }
39
40 public ActionResult AddTwitterAccount()
52 { 41 {
53 var oAuth = new OAuthTwitter(); 42 var oAuth = new OAuthTwitter();
54 43
55 if (Request["oauth_token"] == null) 44 if (Request["oauth_token"] == null)
56 { 45 {
72 return RedirectToAction("Index"); 61 return RedirectToAction("Index");
73 } 62 }
74 return RedirectToAction("Index"); 63 return RedirectToAction("Index");
75 } 64 }
76 65
77 public ActionResult AddBuiltInAccount()
78 {
79 return View();
80 }
81
82 [HttpPost]
83 public ActionResult AddBuiltInAccount(LogOnModel model)
84 {
85 if (ModelState.IsValid)
86 {
87 if (MembershipService.ValidateUser(model.UserName, model.Password))
88 {
89 var personaService = AgendaFactory.GetPersonaService();
90 personaService.AddCuenta(IdentityProviderEnum.BuiltIn, model.UserName);
91 return RedirectToAction("Index");
92 }
93 ModelState.AddModelError("", "The user name or password provided is incorrect.");
94 }
95
96 // If we got this far, something failed, redisplay form
97 return View(model);
98 }
99
100 public ActionResult Remove(string identityProvider, string username) 66 public ActionResult Remove(string identityProvider, string username)
101 { 67 {
102 var personaService = AgendaFactory.GetPersonaService(); 68 var personaService = AgendaFactory.GetPersonaService();
103 69
104 IdentityProviderEnum ip; 70 IdentityProviderEnum ip;