Exemplo n.º 1
0
        public IActionResult Index(CancellationToken token)
        {
            try
            {
                Request.Form.TryGetValue("id_token", out var idToken);
                var jwtToken = _tokenHandler.GetJwtSecurityToken(idToken);

                if (!_tokenHandler.IsAuthorised(jwtToken))
                {
                    return(View("UserInput"));
                }

                ViewData["UserName"] = _tokenHandler.GetUserName(jwtToken);

                var userDetailsFromClaims = _tokenHandler.GetUserDetailsFromClaims(jwtToken);
                var fullBmiReport         = _fullReportBuilder.BuildBmiReport(userDetailsFromClaims);

                return(View(fullBmiReport));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failure happen during validating id_token.");
            }

            return(View("UserInput"));
        }