예제 #1
0
        public async Task <IActionResult> OnGetAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            await LoadAsync(user);

            return(Page());
        }
예제 #2
0
        private void InitializeUserSecurityContext()
        {
            var userId = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            if (userId != null)
            {
                //get logged in user
                applicationUser = userManager.GetUserAsync(_httpContextAccessor.HttpContext.User).Result;
                if (applicationUser != null)
                {
                    SecurityContext                = new UserSecurityContext();
                    SecurityContext.PersonId       = applicationUser.PersonId;
                    SecurityContext.OrganizationId = GetUserOrganization();
                    SetContext(SecurityContext);
                }
            }
        }