Hide auth component when the user is authenticated?

How can I check if a user is authenticated programmatically within my app? I want to hide the auth component if there's no need for it. I am using a custom auth resource.

Hey @Sebpm! You can hide an auth button by adding some JS into the component's Hidden field. For example, if you're authenticating Slack, you could run an REST query (e.g. slackAuthTest) to slacks api "auth.test", and it will return authenticated true. You could then reference this property inside the auth button's hidden field as {{slackAuthTest.data.ok}} to hide the button when the query returns an ok!

For other APIs without this auth test endpoint, you could just check whether the request's result data is not null or if there's an error message.

This hides the button when there's no error!

Would something like this work for you?

This is an option but not preferred. I have forms with multiple input fields and if users realize halfway through that they need to log in because a query has failed, the form refreshes and they lose all their data. This is actually a problem that I am currently facing, and I am trying to mitigate it by hiding the authentication component when they are already authenticated and showing it when they are not authenticated.

Hmm :thinking: How is your form currently configured? How is the data loss occurring (is the page refreshing)? And is it expected that a query fails and the user has to login halfway often?

After logging in using the RESTful API's custom auth flow with a modal, the page automatically refreshes. Unfortunately, there doesn't seem to be an option to disable this feature. Additionally, users will need to re-login every 60 minutes when their token expires.

Ah, got it! Is there a reason you've set the token to expire every 60 minutes? And is there a reason you require users to re-login instead of automatically refreshing?

I'll also create a feature request to *not* refresh the page upon re-authing!

I am currently facing difficulty in utilizing the authentication data from the previous request to populate the refresh token fields in the designated resource. Unfortunately, I was unable to find any relevant information regarding this matter in the documentation.

Would you mind sharing some screenshots of your current setup? Happy to take a look to see how I can help!