Skip to content

This approach aims to replace razor pages of Microsoft.AspNetCore.Identity.UI with Blazor components as separate library.

Notifications You must be signed in to change notification settings

Adlorem/Blazor.Identity.UI

Repository files navigation

Microsoft Identity UI with blazor components.

The aim of this project is to replace Microsoft.AspNetCore.Identity.UI cshtml files and replace them with native blazor components. Library uses middleware to authenticate user and create Blazor version of Microsoft Identity.

Usage/Examples

  1. Add library to your project.
  2. Modify your Program.cs and add this lines:
using Blazor.Identity.UI.Extensions;
using Blazor.Identity.UI.Interfaces;

builder.Services.AddSingleton<IEmailService, EmailService>();

app.UseBlazorIdentityUI();

Remember to implement your IEmailService in executing assembly.

  1. Modify your App.razor and modify following line
@using Blazor.Identity.UI.Common

<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="@SharedComponents.GetAll()">
  1. Modify or add following blazor component to display login in your app header
<AuthorizeView>
    <Authorized>
        <a href="Account/Manage">Hello, @context.User.Identity?.Name!</a>
        <form method="post" action="Account/LogOut">
            <button type="submit" class="nav-link btn btn-link">Log out</button>
        </form>
    </Authorized>
    <NotAuthorized>
        <a href="Account/Register">Register</a>
        <a href="Account/Login">Log in</a>
    </NotAuthorized>
</AuthorizeView>

For further details check BlazorIdeintityUIExample project.

Screenshots

App Screenshot

App Screenshot

About

This approach aims to replace razor pages of Microsoft.AspNetCore.Identity.UI with Blazor components as separate library.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published