Force fail on empty array

I'm currently building simple login page for my app.

It's only meant to send different user type (referred to as job_role).

I run the following SQL query:

SELECT * FROM "employeeTable"
WHERE email = {{ userEmail.value }}
AND password = {{ userPassword.value }}
AND job_role = 'Admin'

However wether the userEmail, Password or job_role are blank/not found an empty array is returned. I need to have the SQL fail when the empty array.

Am I missing something simple here?

Hey @James_Gould - the simplest recommendation I can make if you need the query to fail is to check the length of the results array in the query's transformer and throw an error under certain conditions.

Just to be clear, though, our Terms of Service do not allow users to share account credentials. It sounds like the use case you're describing may be an attempt to circumvent this restriction, but I'm happy to be of assistance if there's additional context you can share!

Hi Darren,

Thanks for this.

I'm not attempting to intentionally circumvent the restricts, it might help if I explain what I attempting to achieve:

I want Admins in retool to have full access to modify themes, etc in the account. Also they will be able to manage user logins.

I want users navigate to the app (via a http link) to hit the retool login, then reach the app login. The reason for using a link is that there will be other apps within the account.

The app login part is only to direct users to the correct page based on their job_role (I.e. Admin goes to Dashboard, Manager goes to management page, regular user goes to new entry page).

I haven't found a way to use the Retool user permissions to point them to the correct page. Hence using making a simple login page.

Does this violate the T&Cs? If so is there an alternative? Should I just allow any of the user to access the all the pages in the app?

As long as each individual user is logging in with unique Retool credentials, you're all good! I just wanted to make that clear. :+1:

Is there anything else I can help with currently or do you think you're good to go?

Hi Darren,

Sorry I've taken so long to get back to you, I actually need the failure to trigger an event Handler (see attached image)

I'm pretty sure the solution I referenced above should do exactly that! By throwing an error in the transformer, you're telling Retool to use the Failure event handler.

Hi Darren,

Perfect! You've truly saved me!

1 Like