After switching to rodauth I was not quite happy with my implementation of the current_account feature. So I decided to dig a bit deeper into the documentation and found a really neat solution.
I was already using dry-effects, but in a rather haphazard way. Looking at the documentation again, I decided to go the rack middleware route as well. If I put the new middleware after rodauth, I can grab the account_id from request.env[“rodauth”] and store it in the effects handler: