Replies: 2 comments 1 reply
-
This is not supported by design as GET requests should not change state like this. Have your logout button submit a POST request to Rodauth's logout endpoint. |
Beta Was this translation helpful? Give feedback.
-
Thanks Jeremy! I've found it was not quite as simple as adding a button that submits a POST request. After I changed this to a POST, I started getting a "Roda::RodaPlugins::RouteCsrf::InvalidToken at /logout" error. I initially worked around this as follows:
However, I didn't want to leave it at that so I used my earlier RODAUTH[0] workaround to bring csrf_tag into scope in the view. My "working" single-click logout link now looks like this:
Again, I'm not sure if there is a better way to accomplish this from a Sinatra app but it does work for me? |
Beta Was this translation helpful? Give feedback.
-
I have been working on a minimal rodauth+sinatra demo and I have had trouble making an "instant" logout button.
By default, rodauth is handling the '/logout' route and displaying a simple page with a "Logout" button. I want to skip this.
I have done this by assigning the rodauth "interface" to a global as follows:
Then I define this route in Sinatra:
This "works" but I wonder if there is a more elegant way to do it? I couldn't spot it easily from the docs?
Beta Was this translation helpful? Give feedback.
All reactions