Workflow for username login instead of email address

I have run myself ragged trying to find something that works. I’ve seen posts from 2017, 2020, 2022, and all of them don’t work.
I’m trying to use the users username to log the user in if they use it. I have this:
I have an input field called “EmailOrUsername” set to text. I’m just testing, assuming there’s just a valid username in the field.
The submit button has the following workflow:
When clicked, step1: Log the user in. Email is set to a “search for Users” which has a type of “User” and a constraint of “Username= Input EmailOrUsername’s value”. So the final email variable is “Search for Users:first item’s email”
When I test and submit, I get the message: “Please include an e-mail”

I’m pretty new to bubble.io and excited about it. I’ve worked with too many platforms far to cumbersome for me to consider them. This one is very promising. In any case, the app data does show a user with the same value as entered into the “EmailOrUsername” input field. How can I test to find out if this found a user even? I don’t know why the issue is happening. I did test with another submit button that just takes the same “EmailOrUsername” field and logs a user in with the value, and as long as an e-mail is in the field, it works fine.

What am I doing wrong? Any ideas? I’ve spent 2 days on this, and even chatGPT has run me in circles. Thank you for reading and any suggestions you may have.

So far, I’ve followed these examples:

Are there any privacy rules applied?

Can you add a screenshot of the workflow you’ve got set up?

I originally tried to distinguish between an e-mail or a username with this. (see image)
image
This is the workflow though:


I don’t know if this helps.
Here’s the data:

And the data in question being looked up:

Hmm I’m not sure about that first make changes wf?

I would do a log the user in wf, have a condition on it to only run if the email/username input contains @ .
So this wf can just directly use the input as the email, rather than doing any search.

Then have a second one which only runs if the email/username input doesn’t contain @, this one then has the do search for user where username = input, first items email address.

That should work, but if you get stuck send me a DM and we can troubleshoot via screen share

Sure, I’ve tried that, where I just test a login, looking up the email using the input. (See Attached). It still says “Please include an e-mail” prompt when submitted.

It looks like there are two workflows coming from the submit button, it’s likely the other one is firing and causing the alert? Add conditional rules to restrict these and only have the applicable one run

I took everything else out. Here’s all that remains:


The same error occurs.

Then it means that is rendering as empty, check privacy rules, and use the debugger in step by step mode on the front end, then you can see it exactly what that search is producing, which is blank / empty

1 Like

Ok. I found the privacy rules needed to make it work. Man I’m a nube with this platform, but it’s cool!


These are settings needed to work.
Thank you Oliver for all your guidance! It is much appreciated!

1 Like

You’re very welcome, but, just a note for best practice.

This would be exposing all your users emails by default, which is bad, fine for testing, bad for production.

I recommend creating a backend workflow which will go and ignore privacy rules and return the users email address, if one exists for that username :slight_smile:

Ok. How then would that be accomplished?

Create a backend workflow which returns an email address if it finds a user account with that exact username, then you use that to log the user in.

If you get stuck send me a DM and we can screen share