Logging in and out from other routes #387
Replies: 2 comments 9 replies
-
If you want to replace the views that Rodauth uses, you can do that by defining a view with the same name in your application and Rodauth will pick it up (one of the specs that uses this: https://github.com/jeremyevans/rodauth/blob/master/spec/login_spec.rb#L272). That's probably a better approach than trying to implement the login action yourself (logout is trivial if you aren't using features such as active_sessions or single_session). Note that logout by default just clears the session, and login by default just sets a couple session values. You can set the same values manually if you know what you are doing. It is possible to call |
Beta Was this translation helpful? Give feedback.
-
Assuming you have retrieved the account in your custom route, you can login as follows: rodauth.account_from_login(account.email)
rodauth.login_session("password") If you also want Rodauth's default redirects and flash message, use |
Beta Was this translation helpful? Give feedback.
-
Hello,
Can I have a few pointers on how to implement login and logout from routes other than those defined in the plugin? As a test, I copied over the login and logout html from their respective routes into new views, but does rodauth expect login and logout submissions to come only from the defined routes?
I know with logout, I can call
rodauth.logout
, though I don't know how recommended this approach is. But as for logging in the user from somewhere other than thelogin
route, what's the best approach?Thank you.
Beta Was this translation helpful? Give feedback.
All reactions