예제 #1
0
 public ActionResult <IdTokenDTO> GetUser()
 {
     try
     {
         var token = jwtProvider.IdToken(HttpContext);
         return(Ok(new IdTokenDTO {
             IdToken = token
         }));
     }
     catch (LeafAuthenticationException lae)
     {
         logger.LogError("User is not authorized to use Leaf. Error:{Error}", lae.Message);
         return(StatusCode(StatusCodes.Status403Forbidden));
     }
     catch (Exception e)
     {
         logger.LogError("Could not produce identity token. Error:{Error}", e.ToString());
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
예제 #2
0
        public async Task <ActionResult <IdTokenDTO> > GetUser()
        {
            try
            {
                var login = await jwtProvider.IdToken(HttpContext);

                return(Ok(new IdTokenDTO {
                    IdToken = login
                }));
            }
            catch (LeafAuthenticationException lae)
            {
                logger.LogError("User is not authorized to use Leaf. Error:{Error} User:{user}", lae.Message, HttpContext.User);
                return(StatusCode(StatusCodes.Status403Forbidden));
            }
            catch (Exception e)
            {
                logger.LogError("Failed to produce identity token. Error:{Error}", e.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }