Forum Academy Marketplace Showcase Pricing Features

Validated user login

Hello,

I’m trying to log in a user but only if he validated his account.
I have a field in my db called “Is validated” which can be yes or no.

My workflow is :

  • click on the login button
    => logs the user in
    => Set state userValidated = search for users’ count where email = input email’s value AND is validated = yes
    => Show message alert “account not validated” only if userValidated = 0
    => Logs the user out

  • click on the login button
    => logs the user in
    => Set state userValidated = search for users’ count where email = input email’s value AND is validated = yes
    => Terminate this workflow only if userValidated = 1

For some reason, I’m not able to login because the variable userValidated is always 0, even though in the database, I have some users that have “isvalidated = yes”

Any idea of what I’m doing wrong here ?

Thanks for your help.

I dont know much on this but what I can say is I dont see any action that actively changes the number. ie when they validate it should move the counter +1.

Buenas noches, saludos, yo también tengo en mi aplicación la obligación de validar el correo electrónico, para ello, cuando el usuario se registra se le envía un email para validar la cuenta.
Al pinchar en el enlace le llevo a la página de verificación y ahí al iniciar sesión ya cambia el dato a validado SI.

A partir de entonces puede iniciar sesión sin problemas :wink:

I’m sorry @robertocarronmartin but I don’t understand spanish :frowning:

@c.martin I’m not sure if I understand what you mean : What I’m trying to achieve here is log the user in, by checking if he’s validated or not. Which means user has already clicked on the validation link and is already validated (or not). But here he tries to login, and depending on wether or not he’s validated, then he must be able to log in or not. You see ?

So the 2 workflows that I created are validation workflow that are supposed to check if the user is validated in the db or not.

But for some reason, the answer is always : no the user is not validated. But in the db some user have the field “is validated” set to yes, so they should be able to login.

Im sorry Im not great at this so my explanation to my thought process may be poor.

How about I tell you what I believe the solution is by laying out the ideal workflow in my mind. Youll still have to fix the issue, but if Im right at least youll know the issue now.

New user creats account.
App assigns validated = untrue
new user recieves validation email.
New user clicks link in validation email
new user navigates back to page
app make changes to thing (current user)
validated = yes

This is not quite what I want to achieve.
What I want is :

New user creates account
App assign “user validated = false” AND “email validated = false”
New user receives validation email
New user navigates to page
App make changes to current user “email validated = true”
Admin goes to Bubble data and set user validated = true manually

I’m going to try and do it.

But my question was about : how can i prevent user from login in if one of the field is false.
If the newly created user doesn’t validate his email address or if the admin doesn’t validate his account, it means that “user validated = false” or “email validated = false”.
In this case, when the user goes to the login page, I want to display a message that says “You can’t login because your account is not validate”.

From what I explained in the beginning of my post, I used a custom query that looks for a user having the email and user_validated field = yes. But I always get 0 result and don’t understand why.

You shouldnt have to do it manually.

the act of them returning to your site from that link should be enough to make a trigger.

Im sorry I cant remember the use case I used it in but it exists. If I remember what I did Ill let you know but Im at a loss right now.

OK, so I just checked my workflows but it looks like it may have been a section deleted long ago…

Hey!
Just realized I haven’t checked in on you.
Did you get it figured out?

Thanks for asking :slight_smile:
In the meantime I was working on other parts of the app.
I’m planning to work again on user validation in a few days.
I’ll let you know !

@bonjourbenny Would you be able to share what you did as I am trying to do the same? I also want to apply two-factor authentication for account setup to make sure the contact info submitted. Do you know how I would create it?

Hello @ktham168,

What I did is :

  • I created a field called “Is validated” which is a yes/no field, set by default to “no”.
  • When user signs up, he receives a link to confirm his email address.
  • Once he clicks on it, his email address is validated but the account is still not validated

If the user tries to sign in while is account is not validated, then he’ll get an error message.
I finally was able to make it work : the query was not returning the good value because the user table is private, and when I was trying to select a user having this email and with the field “Is validated” to yes, it always returned nothing. So what I did is :

When the user clicks on sign in, the first action is : logs the user in.
Then I make the search : Search for all the users that have this email address and whose status “Is validated” = yes.
If this query returns 1 value, then it’s ok, redirect to wherever you want the connected user to go.
In any other cases, display an alert : “Sorry it seems your account was not validated yet” and then logs the user out.

As you can see I don’t do any verification on email validation…
I should but I still don’t know how to check if an user valdated his e-mail address or not…

Thank you, @bonjourbenny , for sharing how you work through validating the email address.
I was thinking of using the two-factor authentication like some of the websites/apps for email and mobile #. As a matter of fact, I downloaded and installed the two-factor authentication element, but don’t quite know how to use it. Have you looked into it?

No @ktham168 I’m sorry but I didn’t check two-factor authentication as I won’t be using it on my app.

I’m posting here again because I was able to do what I want to prevent a user from login in if his account was not previously manually validated by an admin.
But there’s still something that I don’t understand and don’t know how to do :
When the admin goes into the database and wants to manually validate the users , I think he should only validate the users who confirmed their e-mail address. But I don’t know how to do anything on the confirmation page.

When the user clicks on the confirm email link, he’s redirected to a page where I’m not able to log him in, I can’t change any value in his record because I simply don’t know who he is…

I’m not sure if I’m clear but what I want to do is change the value of a given field for the user. I just don’t know how to do this from the “confirm email” page.

Could you please help me ?