Replies: 1 comment 3 replies
-
I'm OK with making I would be surprised if most applications need the full logged in account on all requests. I don't have any applications that require that. I don't consider using it an anti-pattern, but extra database checks are going to decrease performance. It might depend on how much performance matters for your application. If you are running Rails, the relative performance hit from extra database checks is going to be less, compared to if you are running Roda. I would certainly not recommend In terms of sessions being inactive after the grace period expires, maybe it would be a good idea to have the verify_account_grace_period set the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes it can happen that the logged in account doesn't exist in the database anymore. For me a common scenario is manually deleting the account in development as a quick way to start fresh, but I can imagine staging/production scenarios where an account gets deleted by the system for various reasons.
In rodauth-rails, the
#current_account
controller/helper method is currently handling this scenario in the same way as Rodauth's#require_account_session
method. Now, I've since found a way to reuse#require_account_session
instead of duplicating its logic, but I realized that performing a redirection can be unexpected for a#current_account
method either way.I noticed that both
#require_account_session
and#require_account
Rodauth methods are private, so I was wondering whether there is another recommended way in Rodauth to handle this scenario in non-authentication routes, or whether trying to do this is considered an anti-pattern. I was thinking it would be useful if#require_account
(and maybe even#require_account_session
) were public, as then I could recommend using it in Rails instead of#require_authentication
/#require_login
, since most applications will probably want to retrieve the logged in account in all requests anyway.Other than handling deleted accounts, I thought it would also be a convenient way to log out accounts whose unverified grace period expired. If I understand correctly, in applications that use
#require_authentication
/#require_login
and retrieve the account straight from the session value, a user could theoretically continue using the app even after the unverified grace period has expired, as long as they don't close the browser and don't use any authentication routes. This sounds like it might be problematic, but maybe I'm mistaken. Being able to call#require_account
/#require_account_session
would handle that, as#account_from_session
won't find accounts whose unverified grace period has expired.Beta Was this translation helpful? Give feedback.
All reactions