protected override async Task <bool> PostHtmlAsync(IOwinEnvironment context, IClient client, ContentType bodyContentType, CancellationToken cancellationToken) { var executor = new LogoutExecutor(client, _configuration, _handlers, _logger); await executor.HandleLogoutAsync(context, cancellationToken); return(await executor.HandleRedirectAsync(context)); }
protected override async Task <bool> PostAsync( IOwinEnvironment context, IClient client, ContentNegotiationResult acceptContentNegotiationResult, CancellationToken cancellationToken) { var executor = new LogoutExecutor(client, _configuration, _handlers, _logger); await executor.HandleLogoutAsync(context, cancellationToken); if (acceptContentNegotiationResult.ContentType == ContentType.Html) { return(await executor.HandleRedirectAsync(context)); } await JsonResponse.Ok(context); return(true); }
private async Task <bool> HandleCallbackAsync( IOwinEnvironment context, IClient client, IApplication application, IJwt jwt, string nextPath, CancellationToken cancellationToken) { var isNewSubscriber = false; if (jwt.Body.ContainsClaim("isNewSub")) { isNewSubscriber = (bool)jwt.Body.GetClaim("isNewSub"); } var status = jwt.Body.GetClaim("status").ToString(); var isLogin = status.Equals("authenticated", StringComparison.OrdinalIgnoreCase); var isLogout = status.Equals("logout", StringComparison.OrdinalIgnoreCase); var isRegistration = isNewSubscriber || status.Equals("registered", StringComparison.OrdinalIgnoreCase); if (isRegistration) { var grantResult = await ExchangeTokenAsync(application, jwt, cancellationToken); var registrationExecutor = new RegisterExecutor(client, _configuration, _handlers, _logger); var account = await(await grantResult.GetAccessTokenAsync(cancellationToken)).GetAccountAsync(cancellationToken); await registrationExecutor.HandlePostRegistrationAsync(context, account, cancellationToken); return(await LoginAndRedirectAsync( context, client, grantResult, true, nextPath, cancellationToken)); } if (isLogin) { var grantResult = await ExchangeTokenAsync(application, jwt, cancellationToken); return(await LoginAndRedirectAsync( context, client, grantResult, false, nextPath, cancellationToken)); } if (isLogout) { var executor = new LogoutExecutor(client, _configuration, _handlers, _logger); await executor.HandleLogoutAsync(context, cancellationToken); await executor.HandleRedirectAsync(context); return(true); } // json response throw new ArgumentException($"Unknown assertion status '{status}'"); }