Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • paul 11 posts 101 karma points
    Dec 02, 2022 @ 01:23
    paul
    0

    Two Factor Login Authenticator Code Fails Successfully

    Dear all,

    This issue is about two-factor authentication for members on a clean site.

    Umbraco.Cms 10.3.2 GoogleAuthenticator 3.0.0 Clean install on Ubuntu, NGINX, dotnet sdk 6.0.301, docker 20.10.21, latest azure-sql-edge image (tnx Sebastiaan Janssen!)

    I'm using the "New partial view macro from snippets". My goal is to get the Two-factor Authentication to work (for learning purposes). The basic Member Registration and Login is also from a Umbraco Snippet

    All is working well! As a member using the site i can: - create an account, - Log in and out without 2fa, - Update my account to use 2fa, - Log in and out using 2fa!

    But when i log in with 2fa after i enter the code from Google Authenticator it says "invalid code" because:

    <div asp-validation-summary="All" class="text-danger"></div>

    (line 29 from the login snippet) even though the login status (a partial view snippet) says "welcome member!"! The login still asks for the correct authentication code but when i input anything i get a 404 (probably because the UmbTwoFactorLoginController does not want me to redirect back to a Login view since it knows i have logged in!). When i return to my homepage all looks well: i am logged in, the Login view is not present in the navigation anymore and it says "welcome member!". I get no errors in the DevTools (chrome and firefox) and the log files are also not indicating a problem (unless i enter a code again, then i get the 404 and the log says: PostVerify2FACode :: No verified member found, returning 404 ,,, which is incorrect)

    Sumarry: I do log in with 2fa even though it says im logged in successfully it says the 2fa code is incorrect (see picture...)enter image description here

    I think i could fix it in the "UmbTwoFactorLoginController" but i cannot find it. Im working "remote (ssh)" so refractor tools are not working in vs code. It is already compiled to a dll i think though appsettings.json Mode = development.

    I hope i've made my issue clear, it's my first time on this forum!

    Kind regards, Paul

  • Darren McGrath 1 post 21 karma points
    Feb 10, 2023 @ 17:41
    Darren McGrath
    0

    two factor with

    It is because it is expecting a return url to be sent to it. 

    Add on to the UmbracoForm call the return url e.g. 

    @using (Html.BeginUmbracoForm<UmbTwoFactorLoginController>(nameof(UmbTwoFactorLoginController.Verify2FACode),  new { returnUrl = loginModel.RedirectUrl }))
    
  • paul 11 posts 101 karma points
    Feb 10, 2023 @ 22:00
    paul
    100

    Dear Darren,

    Thanks for your reply!

    You are right, this is how i fixed it a few months ago:

    @if (profileModel != null) {
       if (success) {
          profileModel.RedirectUrl = "/";
    

    if put that in front of everything else that came with the QR Registration Macro snippet.

    I think it would be awesome if the snippets would work right out of the box! With a lot of explanatory comments to help beginners.

    Thanks again for your input, i should have posted my fix before, sorry.

    Kind regards, Paul

Please Sign in or register to post replies

Write your reply to:

Draft