Skip to content

Commit

Permalink
Register a default token provider to allow admin to rest password. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek committed May 16, 2024
1 parent 768459c commit 3418d2d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public async Task<IActionResult> ResetPost()
return UserNotFound();
}

return await RemoveTwoFactorProviderAync(user, async () =>
return await RemoveTwoFactorProviderAsync(user, async () =>
{
await UserManager.ResetAuthenticatorKeyAsync(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected async Task SetRecoveryCodesAsync(string[] codes, string userId)
});
}

protected async Task<IActionResult> RemoveTwoFactorProviderAync(IUser user, Func<Task> onSuccessAsync)
protected async Task<IActionResult> RemoveTwoFactorProviderAsync(IUser user, Func<Task> onSuccessAsync)
{
var currentProviders = await GetTwoFactorProvidersAsync(user);

Expand Down
7 changes: 4 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Users/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ public override void ConfigureServices(IServiceCollection services)
// Add ILookupNormalizer as Singleton because it is needed by UserIndexProvider
services.TryAddSingleton<ILookupNormalizer, UpperInvariantLookupNormalizer>();

// Add the default token providers used to generate tokens for reset passwords, change email,
// and for two-factor authentication token generation.
services.AddIdentity<IUser, IRole>();
// Add the default token providers used to generate tokens for an admin to change user's password.
services.AddIdentity<IUser, IRole>()
.AddTokenProvider<DataProtectorTokenProvider<IUser>>(TokenOptions.DefaultProvider);

services.AddTransient<IConfigureOptions<IdentityOptions>, IdentityOptionsConfigurations>();
services.AddPhoneFormatValidator();
// Configure the authentication options to use the application cookie scheme as the default sign-out handler.
Expand Down

0 comments on commit 3418d2d

Please sign in to comment.