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
Fix #16074
  • Loading branch information
MikeAlhayek committed May 16, 2024
1 parent 768459c commit 09f7dcc
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 @@ await DistributedCache.SetAsync(key, data,
});
}

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 09f7dcc

Please sign in to comment.