Example #1
0
        /// <summary>
        /// Signs User into system. If User is already Signed-In, this will update their
        /// Authentication cookie.
        /// </summary>
        private async Task SignInUser(UserLogin userLogin)
        {
            var authenticationProperties = AuthenticationUtils.GetAuthenticationProperties();
            var userRolesResult          = _userRoleReadConductor.FindAll(e => e.UserId == userLogin.UserId);
            var roleIds = userRolesResult.ResultObject?.Select(e => e.RoleId);

            var claims = AuthenticationUtils.GetClaims(
                roleIds: roleIds,
                user: userLogin.User,
                userLogin: userLogin
                );
            var userPrincipal = new ClaimsPrincipal(new ClaimsIdentity(claims, AuthenticationUtils.AUTHENTICATION_TYPE));

            await _httpContext.SignInAsync(AuthenticationUtils.AUTHENTICATION_SCHEME, userPrincipal, authenticationProperties);
        }