How to delay session creation in Rodauth until 2FA confirmation? #214
Replies: 2 comments 4 replies
-
Your approach looks like it's on the right path. Note that |
Beta Was this translation helpful? Give feedback.
-
I discussed this with Jeremy in jeremyevans/rodauth#348, and he provided some good points why Rodauth remembers 1st factor even when 2nd factor auth was aborted. TL;DR Apps like GitHub and HEY also remember the 1st factor, but they hide it by redirecting you to the login page, making it appear as if though you need to re-authenticate with 1st factor, which isn't honest because it gives an illusion that you're logged out. |
Beta Was this translation helpful? Give feedback.
-
Hello, janko Janko Marohnić
I'm using Rodauth in my Rails application and trying to implement a two-factor authentication (2FA) mechanism. Using this guide, I've added a 2FA step on my main page in the form of a sidebar.
Here's my problem: When a user enters their login and password, a session is created before the user confirms 2FA. If the user doesn't confirm 2FA and tries to refresh the page or navigate to another page, they are redirected to '/otp-auth'. I want to avoid this redirection and have the user's session not be created until they confirm 2FA.
I've tried implementing it this way, but without success:
Here's the code I'm using to display 2FA on the sidebar:
I'm curious if there's a way to configure Rodauth such that the session creation is delayed until 2FA confirmation, and how to do it? Any tips or directions would be greatly appreciated.
Thank you in advance for your help.
Beta Was this translation helpful? Give feedback.
All reactions