# Abp.PhoneNumberLogin

ABP version (opens new window) NuGet (opens new window) NuGet Download (opens new window) Discord online (opens new window) GitHub stars (opens new window)

An abp module to avoid duplicate user phone numbers being confirmed and providing phone number confirmation and phone number login features and more.

# Online Demo

We have launched an online demo for this module: https://phonelogin.samples.easyabp.io (opens new window)

# Installation

  1. Install the following NuGet packages. (see how (opens new window))

    • EasyAbp.Abp.PhoneNumberLogin.Application
    • EasyAbp.Abp.PhoneNumberLogin.Application.Contracts
    • (Exclusive) EasyAbp.Abp.PhoneNumberLogin.Domain.OpenIddict
    • (Exclusive) EasyAbp.Abp.PhoneNumberLogin.Domain.Ids4
    • EasyAbp.Abp.PhoneNumberLogin.Domain.Shared
    • EasyAbp.Abp.PhoneNumberLogin.EntityFrameworkCore
    • EasyAbp.Abp.PhoneNumberLogin.HttpApi
    • EasyAbp.Abp.PhoneNumberLogin.HttpApi.Client
    • (Optional) EasyAbp.Abp.PhoneNumberLogin.MongoDB
    • (Optional) EasyAbp.Abp.PhoneNumberLogin.Web
  2. Add DependsOn(typeof(Abp.PhoneNumberLoginXxxModule)) attribute to configure the module dependencies. (see how (opens new window))

  3. Add builder.ConfigureAbpPhoneNumberLogin(); to the OnModelCreating() method in MyProjectMigrationsDbContext.cs.

  4. Add EF Core migrations and update your database. See: ABP document (opens new window).

  5. Specify a auth server in the appsettings.json file of the Web/Host project.

    {
      "AbpPhoneNumberLogin": {
        "AuthServer": {
          "Authority": "https://localhost:44395",
          "ClientId": "MyProjectName_App",
          "ClientSecret": "1q2w3e*"
        }
      }
    }
    
  6. Add the PhoneNumberLogin_credentials grant type in OpenIddictDataSeedContributor.

    grantTypes: new List<string>
    {
        OpenIddictConstants.GrantTypes.AuthorizationCode,
        OpenIddictConstants.GrantTypes.Password,
        OpenIddictConstants.GrantTypes.ClientCredentials,
        OpenIddictConstants.GrantTypes.RefreshToken,
        PhoneNumberLoginConsts.GrantType // add this grant type
    }
    
  7. Run the DbMigrator project to create the client. Notice that you must manually add the grant type if your client already exists.

# Usage

# Razor Pages Phone Number Login

Ensure the EasyAbp.Abp.PhoneNumberLogin.Web module was installed.

  1. Customize the default login page (see demo (opens new window)).

  2. Register an account with a confirmed phone number or confirm your phone number of your existing account.

  3. Log out and try to log in by phone number and password (or verification code).

# Identity Server Token Endpoint

LoginByPhoneNumberAndPassword

# Road map

  • [x] Keep allowing users to set a phone number that has been used by others.
  • [x] Only confirmed phone numbers are allowed to be used for login.
  • [x] Avoid setting a non-numeric phone number.
  • [x] Avoid setting a phone number starting with 0.
  • [x] Avoid duplicate user phone numbers being confirmed.
  • [x] Razor pages log in by phone number and password widget.
  • [ ] Razor pages log in by phone number and verification code widget.
  • [ ] Request token by phone number and password.
  • [ ] Request token by phone number and verification code.
  • [ ] Simply generate and send verification codes.
  • [ ] User confirm Phone number with verification code.
  • [ ] Register an account with phone number and verification code.
  • [ ] Reset password with phone number and verification code.
  • [ ] Using EasyAbp.Abp.VerificationCode module to generate verification codes.
  • [ ] Support EasyAbp integrated login module.
  • [ ] Unit tests.
Last Updated: 11/19/2022, 7:13:35 PM