aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Log message on logout success incorrectly states "Login completed successfully." (Blazor WASM)

Open mmacy opened this issue 3 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

The debug log message for a successful logout in Blazor WebAssembly incorrectly states that a successful login has occurred.

Looks like maybe a bit of copypasta made its way into RemoteAuthenticatorViewCore.Log.cs - note name of the method the attribute decorates:

https://github.com/dotnet/aspnetcore/blob/45fcfb75dd7ca6c548200dde4f7374a9a451039b/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticatorViewCore.Log.cs#L40-L41

Expected Behavior

Upon successful logout in a Blazor WASM project with logging enabled, the log entry should refer to logout instead of login as it does currently.

Essentially, the first line in this snippet:

https://github.com/dotnet/aspnetcore/blob/45fcfb75dd7ca6c548200dde4f7374a9a451039b/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticatorViewCore.Log.cs#L40-L41

Should instead refer to logout, as shown here:

[LoggerMessage(10, LogLevel.Debug, "Logout completed successfully.", EventName = nameof(LogoutCompletedSuccessfully))]
public static partial void LogoutCompletedSuccessfully(ILogger logger);

Steps To Reproduce

  1. Follow the steps for Visual Studio Code in the Microsoft Learn article Secure an ASP.NET Core Blazor WebAssembly standalone app with the Authentication library to create a Blazor WASM app by using the dotnet CLI and the Individual Authentication template.

  2. Add support for successfully logging the user out of your app.

  3. Enable logging as described in the Learn article section, Logging in Blazor WebAssembly apps.

  4. In Program.cs, set the log level to "trace":

    builder.Logging.SetMinimumLevel(LogLevel.Trace);
    
  5. Enable debugging in Visual Studio Code as described in Debug a standalone Blazor WebAssembly app.

  6. Run with debugging in Visual Studio Code.

  7. Sign in to your app with a valid user account.

  8. Sign out of your app.

  9. View the log output in the DEBUG CONSOLE pane in Visual Studio Code (you might need to select Debug Blazor WebAssembly in Browser by using the drop-down).

In the log output, you'll see output similar to the following showing the logout operation being logged as a login operation (the Login completed successfully. line).

dbug: Microsoft.AspNetCore.Components.Routing.Router[2]
      Navigating to component MyAwesomeBlazorWASMApp.Pages.Authentication in response to path 'authentication/logout' with base URI 'https://localhost:7007/'
dbug: Microsoft.AspNetCore.Components.RenderTree.Renderer[3]
      Rendering component 4 of type Microsoft.AspNetCore.Components.Authorization.AuthorizeRouteView
# ...several render events omitted for brevity...
dbug: Microsoft.AspNetCore.Components.RenderTree.Renderer[3]
      Rendering component 8 of type MyAwesomeBlazorWASMApp.Shared.MainLayout
dbug: Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticatorViewCore[10]
      Login completed successfully.
dbug: Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticatorViewCore[12]
      Raising LogoutCompleted event.

Exceptions (if any)

No response

.NET Version

8.0.100-alpha.1.22531.1

Anything else?

~I'll submit a PR with the fix shortly.~ 🙂

Draft PR building now: #45847

mmacy avatar Jan 03 '23 05:01 mmacy

@mmacy thanks for contacting us.

Yes. This indeed looks like a bug. We'll gladly take the PR with your fix. Thanks for the contribution.

javiercn avatar Jan 03 '23 10:01 javiercn

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Jan 03 '23 17:01 ghost

@mmacy thanks for contacting us.

Yes. This indeed looks like a bug. We'll gladly take the PR with your fix. Thanks for the contribution.

Thanks, @javiercn - PR is ready to go:

#45847

mmacy avatar Jan 03 '23 19:01 mmacy