public IActionResult SignOut() { // Initiate the SignOut flow if the user is authenticated if (User.Identity.IsAuthenticated) { var redirectUrl = Request.GetDisplayUrl(); return(SignOut(new Microsoft.AspNetCore.Authentication.AuthenticationProperties { RedirectUri = redirectUrl }, CookieAuthenticationDefaults.AuthenticationScheme, OpenIdConnectDefaults.AuthenticationScheme)); } else { // If the user is signed out already, reply with the relevant success message return(ApiResponseHelper.GetApiResponse(DataConstant.Authentication202)); } }
public IActionResult AcquireToken() { // Return the authentication token if the user is authenticated. if (HttpContext.User.Identity.IsAuthenticated && !string.IsNullOrWhiteSpace(HttpContext.Session.GetString(DataConstant.IdToken))) { return(ApiResponseHelper.GetApiResponse(DataConstant.Authentication201, HttpContext.Session.GetString(DataConstant.IdToken))); } else { // Redirect to authentication flow if the user is not signed-in var redirectUrl = Request.GetDisplayUrl(); return(Challenge( new Microsoft.AspNetCore.Authentication.AuthenticationProperties { RedirectUri = redirectUrl }, OpenIdConnectDefaults.AuthenticationScheme)); } }