0
balessi75 created
ABP 7.0.1 Commercial / Blazor Server / EF / Separated Tenant and Host DBs/ Non-tiered
Hi, If a tenant admin sets two factor to be 'optional' for each user, what would be the recommended approach to defaulting each newly added/registered user to have two-factor turned on. Currently the framework defaults to each AbpUser having two-factor turned off.
Thanks in advance!
2 Answer(s)
-
0
Hi,
You can custom the
UserStore
to override theCreateAsync
method to enable the two-factor by default.For example:
[ExposeServices(typeof(IdentityUserStore))] public class MyIdentityUserStore : IdentityUserStore { public MyIdentityUserStore(IIdentityUserRepository userRepository, IIdentityRoleRepository roleRepository, IGuidGenerator guidGenerator, ILogger<IdentityRoleStore> logger, ILookupNormalizer lookupNormalizer, IdentityErrorDescriber describer = null) : base(userRepository, roleRepository, guidGenerator, logger, lookupNormalizer, describer) { } public override async Task<IdentityResult> CreateAsync(IdentityUser user, CancellationToken cancellationToken = new CancellationToken()) { await SetTwoFactorEnabledAsync(user, true, cancellationToken); return await base.CreateAsync(user, cancellationToken); } }
PS: User must confirm his email and mobile number to use two-factor
-
0
Thanks @liangshiwei, this worked perfectly