Пример #1
0
        private void SingIn(Cliente persona)
        {
            var roles  = new RolBL().GetRolesByUser(persona.Id);
            var claims = new[]
            {
                new Claim(ClaimTypes.Name, persona.Nombre),
                new Claim(ClaimTypes.Email, persona.Email),
                new Claim(ClaimTypes.NameIdentifier, persona.Id.ToString()),
                new Claim(ClaimTypes.Role, String.Join(",", roles.Select(u => u.Descripcion)))
            };
            var identity    = new ClaimsIdentity(claims, "ApplicationCookie");
            var context     = Request.GetOwinContext();
            var authManager = context.Authentication;

            Session["id"] = persona.Id.ToString();
            authManager.SignIn(new AuthenticationProperties {
                IsPersistent = false
            }, identity);
        }