public async Task <LoggedOutResult> LogOut(string logoutId, Option <ClaimsPrincipal> user, Func <string, Task <bool> > schemeSupportsSignoutLookup) { // get context information (client name, post logout redirect URI and iframe for federated signout) var logoutRequest = (await _interaction.GetLogoutContextAsync(logoutId)).SomeNotNull(); var logoutResult = new LoggedOutResult { AutomaticRedirectAfterSignOut = AccountOptions.AutomaticRedirectAfterSignOut, PostLogoutRedirectUri = logoutRequest.Map(x => x.PostLogoutRedirectUri), ClientName = logoutRequest.FlatMap(x => x.ClientName.SomeNotNull().Filter(cn => !string.IsNullOrEmpty(cn)).Else(x.ClientId.SomeNotNull())), SignOutIframeUrl = logoutRequest.Map(x => x.SignOutIFrameUrl), LogoutId = logoutId }; // perform ext ID-provider signout if applicable await user .FlatMap(u => u.FindFirst(JwtClaimTypes.IdentityProvider).SomeNotNull()) .Filter(idpClaim => idpClaim.Value != IdentityServerConstants.LocalIdentityProvider) .MatchSomeAsync(async extIdpClaim => { if (await schemeSupportsSignoutLookup(extIdpClaim.Value)) { if (logoutResult.LogoutId == null) { // if there's no current logout context, we need to create one // this captures necessary info from the current logged in user // before we signout and redirect away to the external IdP for signout logoutResult.LogoutId = await _interaction.CreateLogoutContextAsync(); } logoutResult.ExternalAuthenticationScheme = extIdpClaim.Value; } }); // raise the logout event await user.MatchSomeAsync(u => _events.RaiseAsync(new UserLogoutSuccessEvent(u.GetSubjectId(), u.GetDisplayName()))); return(logoutResult); }
public LoggedOutViewModel(LoggedOutResult logoutResult) { _logoutResult = logoutResult; }