Xano Auth Q: Does Weweb auto logout users when Auth Token expires?

I like @Alexis code! The workflow in question would need to delete the locally stored authentication token then redirect the user to the logout page.

It’s not really a secure method. The token is still good. Any reasonable red teamer would still have access. But a casual user would experience a logout.

1 Like

The global workflow can call the logout xano action, it will clear everything (cookies and plugin variables) :slight_smile:

1 Like

@Alexis you are a GENIUS! This worked perfectly, thank you! And thank you @raydeck for moving the ball forward! I would mark this solved if I could, but I’m not the OP. :slightly_smiling_face:

2 Likes

One follow-up question please, if I may be so presumptuous.

I would also like to set a variable to true when the timeout occurs, so that I can show a message on the Login screen after logout. I figure the variable has to be set to ‘save in local storage’. But I can’t figure out how to update the code to set that variable to true. I tried asking ChatGPT but it’s suggestions either don’t work at all, or cause the logout to occur even when there is user activity.

Thanks.

Hi, you can add it inside your workflow, before the logout and redirection, it doesn’t need to be inside the js code :slight_smile:

Create a boolean variable with preserve on navigation (doesn’t need to be local storage) to store the information. Add a change variable value action on your workflow to toggle it to true.

On the page you redirect your user you can have a modal showing up if this variable is true :slight_smile:

2 Likes

Is there a more elegant way to do this now? Is there a way to just have an overall on “401” error handling than going to each workflow? Also if the collection is fetched automatically where would you put the 401 error handling?

Thanks!

We are discussing about it, we will probably push a new global trigger “on 401 error” (or on request fail and then let you check the type ?), so you can manage global logic here to handle such usecase :slight_smile:

In the meantime, for collections you have an on collection fetch error trigger

1 Like

Hello Alexis,

where to put this javascript code for the resetTimer and executeWorkflow?

In the Head of the Project custom code?
With a around?
And what is the “cans” menu where i can find the workflow id?
thanks for helping.
Stefan

or is there now any plugin for that?