Skip to content

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

Closed
@mmacy

Description

@mmacy

Is there an existing issue for this?

  • 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:

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

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:

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

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions