Beispiel #1
0
        public async Task <IActionResult> Index(string userJson)
        {
            if (User.Identity.IsAuthenticated)
            {
                string token = await _authenticationHelper.GetUserAccessTokenAsync(User.FindFirst(ObjectIdentifierType)?.Value);

                if (String.IsNullOrEmpty(token))
                {
                    return(RedirectToAction(nameof(Error), "Home", new { message = "User not found in token cache. The server may have been restarted. Please sign out and sign in again." }));
                }

                if (!String.IsNullOrEmpty(userJson))
                {
                    var httpClient = new HttpClient();
                    httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    ViewData["Response"] = (await httpClient.PostAsync(
                                                AzureAdOptions.Settings.ServiceBaseAddress + "/api/selfkey/verify",
                                                new StringContent(userJson, Encoding.UTF8, "application/json"))).IsSuccessStatusCode;

                    ViewData["UserJson"] = userJson;
                }
            }

            return(View());
        }