Open Closed

How to customize the login process in a Blazor Web App #7577


User avatar
1
thanhlg created
  • ABP Framework version: v8.2.0
  • UI Type: Blazor Web App
  • Database System: EF Core (SQL Server)

Hi Support Team,

I want to allow login only with a Microsoft account where the email exists in my Person table, rather than logging in with accounts from the AbpUser table. When logging in, the system should check if the email exists in my Person table. If it does, the user should be logged in; if not, an error message should be displayed. What can I do to achieve this in a Blazor Web App?

And I want to log in with Microsoft directly from this page

Thanks

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

14 Answer(s)
  • User Avatar
    0
    thanhlg created

    Can anyone help me? :(

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    ABP must have an account locally(permissions, features ...etc system needs). It can be registered with an external user login.

    you can disabled the local login and local register in the account setting page and only allowed login with an external provider(Microsoft azure, google...etc)

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    thanhlg created

    Hi,

    ABP must have an account locally(permissions, features ...etc system needs). It can be registered with an external user login.

    you can disabled the local login and local register in the account setting page and only allowed login with an external provider(Microsoft azure, google...etc)

    Hi,

    How can I disable local login and only allow login with an external provider?

    And is there a way for me to login with an external provider from this page instead of having to go to the Account/Login page to do so?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    disabled the local account login and configure an external provider

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    thanhlg created

    As for the issue of logging in with an external provider from this page instead of having to go to the Account/Login page, is there a way to do that?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    As for the issue of logging in with an external provider from this page instead of having to go to the Account/Login page, is there a way to do that?

    it will automatically redirect

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    thanhlg created

    As for the issue of logging in with an external provider from this page instead of having to go to the Account/Login page, is there a way to do that?

    it will automatically redirect

    Sorry for not being clear. I know it redirects to https://localhost:44321/Account/Login and then I can click the login with Microsoft button.

    But is there a way to login with Microsoft directly from https://localhost:44321/?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    You can add @attribute [Authorize] to index.cshtml or indexIndexModel

    [Authorize]
    public class IndexModel : ..
    {
    
    }
    
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    thanhlg created

    thanks @liangshiwei

    Is there a way to always enable Microsoft login instead of having to log in first and then enable and configure the client ID and secret?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Is there a way to always enable Microsoft login instead of having to log in first and then enable and configure the client ID and secure

    yes, you can configure it by code.

    public class YourSettingDefinitionProvider : SettingDefinitionProvider
    {
        public override void Define(ISettingDefinitionContext context)
        {
            context.GetOrNull("Abp.Account.IsSelfRegistrationEnabled").DefaultValue = "false";
            context.GetOrNull("Abp.Account.EnableLocalLogin").DefaultValue = "false";
        }
    }
    
    .AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, options =>
    {
        //Personal Microsoft accounts as an example.
        options.AuthorizationEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize";
        options.TokenEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token";
    
        options.ClaimActions.MapCustomJson("picture", _ => "https://graph.microsoft.com/v1.0/me/photo/$value");
        options.SaveTokens = true;
        options.ClientId = xxxx;
        options.ClientSecret = xxxx;
    })
    
    //.WithDynamicOptions<MicrosoftAccountOptions, MicrosoftAccountHandler>(
    //    MicrosoftAccountDefaults.AuthenticationScheme,
    //    options =>
    //    {
    //        options.WithProperty(x => x.ClientId);
    //        options.WithProperty(x => x.ClientSecret, isSecret: true);
    //    }
    //)
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    thanhlg created

    hi I can't find where to change this icon in Blazor Web App

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    you can add your favicon.svg to wwwroot folder

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    thanhlg created

    hi @liangshiwei

    I am using the event bus to sync data from my Person table to AbpUser and vice versa to ensure that login is only allowed if the email of the person exists in the Person table. However, properties like Email and UserName of IdentityUser are protected internal set, so I cannot update them when there are changes in the Person table. What should I do now?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    please create a new ticket, thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.