Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register a default token provider to allow admin to rest password. #16075

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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