Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlcf88 committed Apr 13, 2024
2 parents 30cccdd + ee37461 commit 5d471aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ An abp module to avoid duplicate user phone numbers being confirmed and providin

1. Add `DependsOn(typeof(Abp.PhoneNumberLoginXxxModule))` attribute to configure the module dependencies. ([see how](https://github.com/EasyAbp/EasyAbpGuide/blob/master/docs/How-To.md#add-module-dependencies))

1. Add `builder.ConfigureAbpPhoneNumberLogin();` to the `OnModelCreating()` method in **MyProjectMigrationsDbContext.cs**.
1. Add `builder.ConfigurePhoneNumberLogin();` to the `OnModelCreating()` method in **MyProjectMigrationsDbContext.cs**.

1. Add EF Core migrations and update your database. See: [ABP document](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=MVC&DB=EF#add-database-migration).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public virtual async Task<SendVerificationCodeResult> SendVerificationCodeAsync(

var result = await _phoneNumberLoginVerificationCodeSender.SendAsync(input.PhoneNumber, code,
input.VerificationCodeType,
new {LifespanMinutes = Math.Floor(await GetRegisterCodeCacheSecondsAsync() / 60f)});
new { LifespanMinutes = Math.Floor(await GetRegisterCodeCacheSecondsAsync() / 60f) });

return result ? new SendVerificationCodeResult(SendVerificationCodeResultType.Success) : new SendVerificationCodeResult(SendVerificationCodeResultType.SendsFailure);
}
Expand All @@ -80,7 +80,6 @@ public virtual async Task<IdentityUserDto> RegisterAsync(RegisterWithPhoneNumber

public virtual async Task<ConfirmPhoneNumberResult> ConfirmPhoneNumberAsync(ConfirmPhoneNumberInput input)
{

var result = await GetValidateResultAsync(input.PhoneNumber, input.VerificationCode, VerificationCodeType.Register);

if (!result)
Expand Down Expand Up @@ -159,7 +158,6 @@ public virtual async Task<string> RefreshTokenAsync(RefreshTokenInput input)

protected virtual async Task<bool> GetValidateResultAsync(string phoneNumber, string code, VerificationCodeType type)
{

switch (type)
{
case VerificationCodeType.ResetPassword:
Expand Down Expand Up @@ -189,7 +187,6 @@ protected virtual async Task<bool> GetValidateResultAsync(string phoneNumber, st
}

return false;

}

protected virtual async Task<TokenResponse> RequestAuthServerLoginByCodeAsync(string phoneNumber, string code)
Expand All @@ -198,16 +195,16 @@ protected virtual async Task<TokenResponse> RequestAuthServerLoginByCodeAsync(st

var request = new TokenRequest
{
Address = _configuration["AbpPhoneNumberLogin:AuthServer:Authority"] + "/connect/token",
Address = $"{_configuration["AbpPhoneNumberLogin:AuthServer:Authority"]}/connect/token",
GrantType = PhoneNumberLoginConsts.GrantType,

ClientId = _configuration["AbpPhoneNumberLogin:AuthServer:ClientId"],
ClientSecret = _configuration["AbpPhoneNumberLogin:AuthServer:ClientSecret"],

Parameters =
{
{"phone_number", phoneNumber},
{"code", code}
{ "phone_number", phoneNumber },
{ "code", code }
}
};

Expand All @@ -222,16 +219,16 @@ protected virtual async Task<TokenResponse> RequestAuthServerLoginByPasswordAsyn

var request = new TokenRequest
{
Address = _configuration["AbpPhoneNumberLogin:AuthServer:Authority"] + "/connect/token",
Address = $"{_configuration["AbpPhoneNumberLogin:AuthServer:Authority"]}/connect/token",
GrantType = PhoneNumberLoginConsts.GrantType,

ClientId = _configuration["AbpPhoneNumberLogin:AuthServer:ClientId"],
ClientSecret = _configuration["AbpPhoneNumberLogin:AuthServer:ClientSecret"],

Parameters =
{
{"phone_number", phoneNumber},
{"password", password}
{ "phone_number", phoneNumber },
{ "password", password }
}
};

Expand All @@ -246,7 +243,7 @@ protected virtual async Task<TokenResponse> RequestAuthServerRefreshAsync(string

var request = new RefreshTokenRequest
{
Address = _configuration["AbpPhoneNumberLogin:AuthServer:Authority"] + "/connect/token",
Address = $"{_configuration["AbpPhoneNumberLogin:AuthServer:Authority"]}/connect/token",

ClientId = _configuration["AbpPhoneNumberLogin:AuthServer:ClientId"],
ClientSecret = _configuration["AbpPhoneNumberLogin:AuthServer:ClientSecret"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ public virtual async Task<IdentityUser> CreateAsync(string phoneNumber, string u

protected virtual Task<string> GenerateUserNameAsync()
{
return Task.FromResult("Phone_" + Guid.NewGuid());
return Task.FromResult($"Phone_{Guid.NewGuid()}");
}

protected virtual Task<string> GenerateEmailAsync()
{
return Task.FromResult(Guid.NewGuid() + "@fake-email.com");
return Task.FromResult($"{Guid.NewGuid()}@fake-email.com");
}

}
}

0 comments on commit 5d471aa

Please sign in to comment.