btcpayserver/BTCPayServer/Security/OpenId/LogoutEventHandler.cs

36 lines
1.2 KiB
C#
Raw Normal View History

using System;
using System.Threading.Tasks;
using BTCPayServer.Data;
using BTCPayServer.Models;
using Microsoft.AspNetCore.Authentication;
2019-10-08 15:21:30 +09:00
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using OpenIddict.Core;
using OpenIddict.Server;
2019-10-08 15:21:30 +09:00
using Microsoft.AspNetCore;
using OpenIddict.Server.AspNetCore;
2019-10-18 21:36:32 +09:00
namespace BTCPayServer.Security.OpenId
{
2019-10-08 15:21:30 +09:00
public class LogoutEventHandler : IOpenIddictServerHandler<OpenIddictServerEvents.HandleLogoutRequestContext>
{
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-10-08 15:21:30 +09:00
_signInManager = signInManager;
}
2019-10-08 15:21:30 +09:00
public async ValueTask HandleAsync(
OpenIddictServerEvents.HandleLogoutRequestContext notification)
{
await _signInManager.SignOutAsync();
}
}
}