2019-07-01 05:39:25 +02:00
|
|
|
using System;
|
|
|
|
using System.Threading.Tasks;
|
2019-08-30 00:24:42 +09:00
|
|
|
using BTCPayServer.Data;
|
2019-07-01 05:39:25 +02:00
|
|
|
using BTCPayServer.Models;
|
|
|
|
using Microsoft.AspNetCore.Authentication;
|
2019-10-08 15:21:30 +09:00
|
|
|
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2019-07-01 05:39:25 +02:00
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
using Microsoft.Extensions.Options;
|
2019-08-29 09:25:16 +02:00
|
|
|
using OpenIddict.Core;
|
2019-07-01 05:39:25 +02:00
|
|
|
using OpenIddict.Server;
|
2019-10-08 15:21:30 +09:00
|
|
|
using Microsoft.AspNetCore;
|
|
|
|
using OpenIddict.Server.AspNetCore;
|
2019-07-01 05:39:25 +02:00
|
|
|
|
|
|
|
namespace BTCPayServer.Authentication.OpenId
|
|
|
|
{
|
2019-10-08 15:21:30 +09:00
|
|
|
public class LogoutEventHandler : IOpenIddictServerHandler<OpenIddictServerEvents.HandleLogoutRequestContext>
|
2019-07-01 05:39:25 +02:00
|
|
|
{
|
2019-10-08 15:21:30 +09:00
|
|
|
protected readonly SignInManager<ApplicationUser> _signInManager;
|
|
|
|
public static OpenIddictServerHandlerDescriptor Descriptor { get; } =
|
|
|
|
OpenIddictServerHandlerDescriptor.CreateBuilder<OpenIddictServerEvents.HandleLogoutRequestContext>()
|
|
|
|
.UseScopedHandler<LogoutEventHandler>()
|
|
|
|
.Build();
|
|
|
|
public LogoutEventHandler(SignInManager<ApplicationUser> signInManager)
|
2019-07-01 05:39:25 +02:00
|
|
|
{
|
2019-10-08 15:21:30 +09:00
|
|
|
_signInManager = signInManager;
|
2019-07-01 05:39:25 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 15:21:30 +09:00
|
|
|
public async ValueTask HandleAsync(
|
|
|
|
OpenIddictServerEvents.HandleLogoutRequestContext notification)
|
2019-07-01 05:39:25 +02:00
|
|
|
{
|
|
|
|
await _signInManager.SignOutAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|