Starts in:
0 DAY
1 HR
7 MIN
17 SEC
Starts in:
0 D
1 H
7 M
17 S
Open Closed

Verify email address by sending a code instead of a verification URL #2105


User avatar
0
sukeshchand created

Is there any built-in functionality available in ABO.IO to verify the email address by sending a verification code instead of a verification URL, Also verify the email before saved into the database. (save only if verification got successful)

I can see some functions available to verify the email by using the verification link. But which is not really works with mobile app development.

_userManager.GenerateEmailConfirmationTokenAsync(user1) var verified = _userManager.ConfirmEmailAsync(user1, token);

The requirement is for the mobile app backend.

  • ABP Framework version: v4.4.2

3 Answer(s)
  • User Avatar
    1
    maliming created
    Support Team Fullstack Developer

    hi

    ChangeEmailTokenProvider will use DataProtectorTokenProvider to generate and verify tokens by default, https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.tokenoptions.changeemailtokenprovider?view=aspnetcore-6.0 https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.dataprotectortokenprovider-1?view=aspnetcore-6.0

    You can customize a token provicer to generate short digital codes. For example PhoneNumberTokenProvider https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.phonenumbertokenprovider-1?view=aspnetcore-6.0 https://github.com/aspnet/AspNetIdentity/blob/main/src/Microsoft.AspNet.Identity.Core/PhoneNumberTokenProvider.cs#L24

    Of course, you also need to change the built-in email sending and verification UI and business code.

  • User Avatar
    0
    sukeshchand created

    Hi,

    Thanks for the replay,

    Your replay is infomative,

    The CustomEmailConfirmationTokenProvider can be added from the ConfigureServices.

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddIdentity<ApplicationUser, IdentityRole>(options =>
        {
            options.Tokens.EmailConfirmationTokenProvider = "CustomEmailConfirmation";
        })
        .AddEntityFrameworkStores<AbpDbContext>()
        .AddDefaultTokenProviders()
        .AddTokenProvider
        <CustomEmailConfirmationTokenProvider<ApplicationUser>>("CustomEmailConfirmation");        
        }
    }
    

    But in the case of ABP.IO the IdentityServer and related properties are is configured in the Inherited ABP module

    ProjectABPModule: AbpModule
    {
    public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
        **app.UseIdentityServer();**
    

    My question is how do I change/configure CustomEmailConfirmationTokenProvider from this AbpModule?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://github.com/abpframework/abp/blob/48c52625f4c4df007f04d5ac6368b07411aa7521/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs#L12-L21

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06