public async Task <LoggedOutViewModel> BuildLoggedOutViewModelAsync(string logoutId)
        {
            // get context information (client name, post logout redirect URI and iframe for federated signout)
            var logout = await this.interactionService.GetLogoutContextAsync(logoutId);

            var vm = new LoggedOutViewModel
            {
                AutomaticRedirectAfterSignOut = true,
                PostLogoutRedirectUri         = logout?.PostLogoutRedirectUri,
                ClientName       = logout?.ClientId,
                SignOutIframeUrl = logout?.SignOutIFrameUrl,
                LogoutId         = logoutId
            };

            var user = this.httpContextAccessor.HttpContext.User;

            if (user == null)
            {
                return(vm);
            }

            var identityProvider = user.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;

            if (identityProvider != null && !string.Equals(identityProvider, IdentityServerConstants.LocalIdentityProvider, StringComparison.InvariantCultureIgnoreCase))
            {
                var providerSupportsSignout = await HttpContextExtensions.GetSchemeSupportsSignOutAsync(this.httpContextAccessor.HttpContext, identityProvider);

                if (providerSupportsSignout)
                {
                    if (vm.LogoutId == null)
                    {
                        // if there's no current logout context, we need to create one
                        // this captures necessary info from the current logged in user
                        // before we signout and redirect away to the external IdP for signout
                        vm.LogoutId = await this.interactionService.CreateLogoutContextAsync();
                    }

                    vm.ExternalAuthenticationScheme = identityProvider;
                }

                if (vm.LogoutId == null)
                {
                    // if there's no current logout context, we need to create one
                    // this captures necessary info from the current logged in user
                    // before we signout and redirect away to the external IdP for signout
                    vm.LogoutId = await this.interactionService.CreateLogoutContextAsync();
                }

                vm.ExternalAuthenticationScheme = identityProvider;
            }

            return(vm);
        }
        public async Task <LoggedOutViewModel> BuildLoggedOutViewModelAsync(string logoutId)
        {
            // get context information (client name, post logout redirect URI and iframe for federated signout)
            var logout = await _interaction.GetLogoutContextAsync(logoutId);

            var vm = new LoggedOutViewModel
            {
                AutomaticRedirectAfterSignOut = AccountOptions.AutomaticRedirectAfterSignOut,
                PostLogoutRedirectUri         = logout?.PostLogoutRedirectUri,
                ClientName       = logout?.ClientId,
                SignOutIframeUrl = logout?.SignOutIFrameUrl,
                LogoutId         = logoutId
            };

            var user = _httpContextAccessor.HttpContext.User;

            if (user?.Identity.IsAuthenticated == true)
            {
                var idp = user.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;
                if (idp != null && idp != IdentityServer4.IdentityServerConstants.LocalIdentityProvider)
                {
                    var providerSupportsSignout = await HttpContextExtensions.GetSchemeSupportsSignOutAsync(_httpContextAccessor.HttpContext, idp);

                    if (providerSupportsSignout)
                    {
                        if (vm.LogoutId == null)
                        {
                            // if there's no current logout context, we need to create one
                            // this captures necessary info from the current logged in user
                            // before we signout and redirect away to the external IdP for signout
                            vm.LogoutId = await _interaction.CreateLogoutContextAsync();
                        }

                        vm.ExternalAuthenticationScheme = idp;
                    }
                }
            }

            return(vm);
        }