Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Domain/IdentityContext.cs @ 179:1deccd6c3cb2
Aplicando seguridad x roles en sitio web
author | nelopauselli |
---|---|
date | Mon, 08 Aug 2011 15:24:26 -0300 |
parents | 7a2eeb9e9bf9 |
children |
comparison
equal
deleted
inserted
replaced
178:33e57fd1a6c9 | 179:1deccd6c3cb2 |
---|---|
1 using System; | 1 using System; |
2 using System.Collections.Generic; | |
3 using System.Linq; | |
2 using AltNetHispano.Agendas.Domain.Exceptions; | 4 using AltNetHispano.Agendas.Domain.Exceptions; |
3 using AltNetHispano.Agendas.Domain.Repositories; | 5 using AltNetHispano.Agendas.Domain.Repositories; |
4 | 6 |
5 namespace AltNetHispano.Agendas.Domain | 7 namespace AltNetHispano.Agendas.Domain |
6 { | 8 { |
44 var identification = new Identification(userName); | 46 var identification = new Identification(userName); |
45 | 47 |
46 var cuenta = _personaRepository.GetCuenta(identification.IdentityProvider, identification.LogonName); | 48 var cuenta = _personaRepository.GetCuenta(identification.IdentityProvider, identification.LogonName); |
47 return cuenta != null ? cuenta.Persona : null; | 49 return cuenta != null ? cuenta.Persona : null; |
48 } | 50 } |
51 | |
52 public static bool IsInRole(IEnumerable<string> roles) | |
53 { | |
54 var persona = GetUsuario(); | |
55 return IsInRole(persona, roles); | |
56 } | |
57 | |
58 public static bool IsInRole(Persona persona, IEnumerable<string> roles) | |
59 { | |
60 if (persona == null) return false; | |
61 return roles.Any(role => persona.Roles.Contains(role)); | |
62 } | |
49 } | 63 } |
50 } | 64 } |