private async Task SignIn(string userId, IEnumerable <Claim> claims, bool isPersistent) { User user = await Users.Find(userId) as User; if (user != null) { // Replace UserIdentity claims with the application specific claims IList <Claim> userClaims = IdentityConfig.RemoveUserIdentityClaims(claims); IdentityConfig.AddUserIdentityClaims(userId, user.UserName, userClaims); IdentityConfig.AddRoleClaims(await Roles.GetRolesForUser(userId), userClaims); IdentityConfig.SignIn(HttpContext, userClaims, isPersistent); } }