umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.43k stars 2.67k forks source link

UserLogoutSuccessNotification does not seem to fire when clicking backoffice logout button. #16869

Open MrPels opened 2 months ago

MrPels commented 2 months ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

14.1.1

Bug summary

I am trying to setup an event listener for the logout event "UserLogoutSuccessNotification" when an user wants to logout in the backoffice sidepanel in Umbraco v14. The documentation on how to do this is identical to the one described in v13. But it is no longer being triggered by the logout button. (see screenshot). In other words it works in v13 but not v14.

However in v14, it seems the user is always redirected to /umbraco/logout instead of triggering the event. The page itself seems to be a 1:1 copy of the umbraco login page.

I want to use the "UserLogoutSuccessNotification" event to set "SignOutRedirectUrl" so it redirects the user directly to my external ad provider for logout.

sidepanellogin

Resource https://docs.umbraco.com/umbraco-cms/reference/security/backofficeusermanager-and-notifications

Specifics

Browser: Chrome 127.0.6533.89

Steps to reproduce

In order to reproduce the issue spin up a new fresh Umbraco install for v13 and v14

The same code is used in v13 and v14. Start by createing the event handler

` public class UserLogoutSuccessEventHandler : INotificationHandler { private readonly IOptions _azureOptions;

    public UserLogoutSuccessEventHandler(IOptions<AzureAdOptions> azureOptions)
    {
        _azureOptions = azureOptions;
    }

    public void Handle(UserLogoutSuccessNotification notification)
    {
        notification.SignOutRedirectUrl = $"{_azureOptions.Value.Instance}{_azureOptions.Value.TenantId}/oauth2/v2.0/logout?post_logout_redirect_uri={_azureOptions.Value.PostLogoutRedirectUri}";
    }
}

`

And then register it in program.cs

builder.CreateUmbracoBuilder() .AddBackOffice() .AddWebsite() .AddDeliveryApi() .AddComposers() .AddNotificationHandler<UserLogoutSuccessNotification, UserLogoutSuccessEventHandler>() //Logout event handler added .AddOpenIdConnectAuthentication() //Custom external AD provider .Build();

The "Handle" method should then be hit when you click the logout button in the backoffice.

Expected result / actual result

I expect that the backoffice user is redirected directly to the defined "SignOutRedirectUrl" specified in the event handler when clicking the logout button.

But the event is not hit, and the user is always redirected to "/umbraco/logout"


This item has been added to our backlog AB#44593

github-actions[bot] commented 2 months ago

Hi there @MrPels!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face: