public async Task <ApiResponse> Logout()
        {
            var response = await _accountManager.Logout(User);

            var vm = await _accountManager.BuildLoggedOutViewModelAsync(User, HttpContext, null);

            // check if we need to trigger sign-out at an upstream identity provider
            if (vm.TriggerExternalSignout)
            {
                // build a return URL so the upstream provider will redirect back
                // to us after the user has logged out. this allows us to then
                // complete our single sign-out processing.
                string url = Url.Action("Logout", new { logoutId = vm.LogoutId });

                // this triggers a redirect to the external provider for sign-out
                SignOut(new AuthenticationProperties {
                    RedirectUri = url
                }, vm.ExternalAuthenticationScheme);
            }

            return(response);
        }