Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs @ 179:1deccd6c3cb2
Aplicando seguridad x roles en sitio web
author | nelopauselli |
---|---|
date | Mon, 08 Aug 2011 15:24:26 -0300 |
parents | 3c70b0d8bd69 |
children | beeb06da4398 |
comparison
equal
deleted
inserted
replaced
178:33e57fd1a6c9 | 179:1deccd6c3cb2 |
---|---|
1 using System.Web.Mvc; | 1 using System.Web.Mvc; |
2 using System.Web.Routing; | 2 using System.Web.Routing; |
3 using System.Web.Security; | |
4 using AltNetHispano.Agendas.Domain; | 3 using AltNetHispano.Agendas.Domain; |
5 using AltNetHispano.Agendas.Factories; | 4 using AltNetHispano.Agendas.Factories; |
6 using AltNetHispano.Agendas.Twitter; | 5 using AltNetHispano.Agendas.Twitter; |
7 using AltNetHispano.Agendas.Web.Models; | |
8 using AltNetHispano.Agendas.Web.Services; | 6 using AltNetHispano.Agendas.Web.Services; |
9 | 7 |
10 namespace AltNetHispano.Agendas.Web.Controllers | 8 namespace AltNetHispano.Agendas.Web.Controllers |
11 { | 9 { |
12 public class AccountController : Controller | 10 public class AccountController : Controller |
13 { | 11 { |
14 | 12 private IFormsAuthenticationService _formsService; |
15 public IFormsAuthenticationService FormsService { get; set; } | |
16 | 13 |
17 protected override void Initialize(RequestContext requestContext) | 14 protected override void Initialize(RequestContext requestContext) |
18 { | 15 { |
19 if (FormsService == null) { FormsService = new FormsAuthenticationService(); } | 16 if (_formsService == null) { _formsService = new FormsAuthenticationService(); } |
20 | 17 |
21 base.Initialize(requestContext); | 18 base.Initialize(requestContext); |
22 } | 19 } |
23 | 20 |
24 public ActionResult LogOn() | 21 public ActionResult LogOn() |
25 { | 22 { |
26 return View(); | 23 return View(); |
58 nombre = nombre.Replace('\u00d1', 'Ñ'); | 55 nombre = nombre.Replace('\u00d1', 'Ñ'); |
59 | 56 |
60 var personaService = AgendaFactory.GetPersonaService(); | 57 var personaService = AgendaFactory.GetPersonaService(); |
61 personaService.CreateIfNotExist(IdentityProviderEnum.Twitter, username, nombre); | 58 personaService.CreateIfNotExist(IdentityProviderEnum.Twitter, username, nombre); |
62 | 59 |
63 FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.Twitter]+username, false); | 60 _formsService.SignIn(Identification.Map[(int)IdentityProviderEnum.Twitter]+username, false); |
64 return RedirectToAction("Index", "Home"); | 61 return RedirectToAction("Index", "Home"); |
65 } | 62 } |
66 | 63 |
67 ModelState.AddModelError("", "The user name or password provided is incorrect."); | 64 ModelState.AddModelError("", "The user name or password provided is incorrect."); |
68 | 65 |
69 return RedirectToAction("LogOn"); | 66 return RedirectToAction("LogOn"); |
70 } | 67 } |
71 | 68 |
72 public ActionResult LogOff() | 69 public ActionResult LogOff() |
73 { | 70 { |
74 FormsService.SignOut(); | 71 _formsService.SignOut(); |
75 return RedirectToAction("Index", "Home"); | 72 return RedirectToAction("Index", "Home"); |
76 } | 73 } |
77 } | 74 } |
78 } | 75 } |