How to trigger a query after using the auth component to log in?

I just set up Custom Auth mode as described here. I followed the tutorial pretty much exactly, so I have a form step, an API call step, and a "define a variable" step where I define a TOKEN to be used in all subsequent calls to my API. This works as expected.

However, I'd like to trigger a query after a user attempts to log in. For instance, I'd like to set the value of an error message if the login attempt failed, trigger an API call to check if the user is an admin after a successful login attempt, and set some environment variables to toggle the hidden status of components.

I don't see any way to trigger a query on success using the Auth component, the way there is for other components. Basically all you can do is rename or hide the modal button.

Any ideas for a way to trigger a query after the user successfully logs in? (Bonus if you know how to change the success message from Successfully authed! to something else, or suppress the default error message for a failed login!)

Hi lauren! Did you end up finding a way to do this? I'm currently running into the same problem. I want to hide the button after logging in (so a trigger on success would be ideal)

Hi Sebas,

Currently we don't have that functionality, however the most common workaround flow is something like this:

  • on page load, call a query that requires auth
  • if it fails, hide everything and show just the login button
  • if it succeeds, show the normal app
    \

but the login button is still not hidden?

Hey @Ah_Is! Are you logging into a custom auth modal and then you're noticing the button persist in the app?

yes

Got it! I added your +1 to the internal feature request thread :slightly_smiling_face:

In the meantime, our current best workaround would be to follow Alex’s post above:

- On page load, call a query that requires auth
- In your button’s “Hidden” property, set the condition to something like {{!query.error}} to hide the component if there’s no error

but if we do as you say and the token we get when we enter and exit the application is still valid, since the data comes without any problems without pressing the login button, the table becomes active and the login button is hidden.

but if we do as you say and the token we get when we enter and exit the application is still valid, since the data comes without any problems without pressing the login button, the table becomes active and the login button is hidden.

Is it possible to prevent this???

It sounds like the best way to prevent this would be to force an auth expiration on your resource side. If your resource expires every 30 minutes, for example, you could ensure that the query to validate will fail and the button will appear.

Just to double check, you want the data to only appear after the login button has been clicked, is that correct? :slight_smile: