private async Task SignIn(AppUser user) { var identity = await userManager.CreateIdentityAsync( user, DefaultAuthenticationTypes.ApplicationCookie); GetAuthenticationManager().SignIn(identity); }
public async Task <ClaimsIdentity> GenerateUserIdentityAsync(Microsoft.AspNet.Identity.UserManager <WfpUser, string> manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here try { using (WfpictContext ctx = new WfpictContext()) { var userId = userIdentity.GetUserId(); var user = ctx.Users.Include(x => x.Roles).FirstOrDefault(x => x.Id == userId); if (user != null) { foreach (var role in user.Roles) { var roleClaims = ctx.RoleClaims.Include("Claim").Where(x => x.RoleId == role.RoleId); foreach (var roleClaim in roleClaims) { userIdentity.AddClaim(new Claim(ClaimTypes.UserData, roleClaim.Claim.ClaimValue)); } } } } } catch (Exception ex) { // ignored } return(userIdentity); }
public async Task <ClaimsIdentity> GenerateUserIdentityAsync(Microsoft.AspNet.Identity.UserManager <MarketplaceUser> manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here return(userIdentity); }
public async Task <ClaimsIdentity> GenerateUserIdentityAsync(Microsoft.AspNet.Identity.UserManager <ApplicationUser> manager) { // Observe que o authenticationType deve corresponder àquele definido em CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); // Adicionar declarações de usuário personalizado aqui return(userIdentity); }
//from webapi for OWin public async Task <ClaimsIdentity> GenerateUserIdentityAsync(Microsoft.AspNet.Identity.UserManager <AspNetIdentityUser, string> manager, string authenticationType) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, authenticationType); // Add custom user claims here return(userIdentity); }
public async Task <ClaimsIdentity> GenerateUserIdentityAsync(Microsoft.AspNet.Identity.UserManager <eCommerceUser> manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here userIdentity.AddClaim(new Claim("Email", Email)); userIdentity.AddClaim(new Claim("Picture", this.Picture != null ? this.Picture.URL : string.Empty)); return(userIdentity); }