Base solution for your next web application
Open Closed

2FA Authentication not working for tenant logins #11419


User avatar
0
kylem created

What is your product version? 11.0.0

What is your product type (Angular or MVC)? Angular

What is product framework type (.net framework or .net core)? .net core

Hi,

Recently we tried enabling 2FA Authentication.

It worked well for Host login - I was able to use email as a second factor in authentication

When I tried using GoogleAuthenticator in tenant login, after successfully passing first phase, I was presented with:

and after clicking the Submit I got: Security code could not be sent! error:

This might have something to do with the fact that we are using login without tenant (we made some modifications with your help in the past to achieve it).

Thanks, Peja


3 Answer(s)
  • User Avatar
    0
    kylem created

    Update:

    I got it working by applying changes similar to what we did earlier for 'removing tenant from the login screen'.

    I added following code to TokenAuthController.SendTwoFactorAuthCode() Can you please review and let me know if this is correct change and if something should be removed or added?

    [HttpPost]
    public async Task SendTwoFactorAuthCode([FromBody] SendTwoFactorAuthCodeModel model)
    {
        using (UnitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))
        {
            var user = await _userManager.GetUserByIdAsync(model.UserId);
            var tenantId = await _userManager.TryGetTenantIdOfUser(user.UserName);
    
            //var cacheKey = new UserIdentifier(AbpSession.TenantId, model.UserId).ToString();
            var cacheKey = new UserIdentifier(tenantId, model.UserId).ToString();
            ...
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @kylem

    Thanks for the update. Yes, this approach seems fine. Since you have removed the tenant selection from login page, you need to manually find the tenant of the user and use it in the cache key.

  • User Avatar
    0
    kylem created

    Thanks for the confirmation. I will close the issue. Peja