Forum Academy Marketplace Showcase Pricing Features

How to make several kinds of users in the application

Hello everybody.

I would like to make make an app for 3 kinds of user: Admin , A & B

I made already a condition that make me the admin “if user’s email = (my mail adress)” but if i want to give someone else the admin status i guess there is a better way.

But the main probleme is for the users A & B.

I made 4 different buttons: log in as A sign up as A Log in as B Sign up as B

When i tried the apps i could log in as B with the mail and password of a A user.

And that’s not something I want.

Is anyone can help me on how i should make the conditions etc…

Thanks for the help

Here’s a simple solution

  1. For different users, add a property to User
    Say I want a User as Seller (A) or Customer (B) or Admin. Create a property of the User to be “User Type” (text).
    Then for A & B when a user signs up, depending on a checkbox create the User as a Seller or Customer by setting the text of “User Type” to “Seller” or “Customer”

For Admin you can change the “User type” to “Admin” in the backend yourself. But this solution means a user can only be A or B or Admin

Then you can restrict your app according to the text of “User Type”

1 Like

Sometimes I also add on the index:

For clients -
When page is loaded and user type is client go to page xyz.

For sellers -
When user type is seller go to page abc.

When both types of users have access to the same page two different containers can be created with contents in it.
Client container - visible when user type is client
Seller container visible when user type is seller

There are other ways of doing it as well, depending on what you want to do

Thank you very much both of you.

It will be very helpful :slight_smile:

1 Like

Hello guys.

I am having troubles with the process of making the “type of user”

In my app i go to the workflow of the button “sign up as user type A” and in the action “sign the user up” then I click on the “+ save some additional data” and I put the new characteristic User type = type A.

Then in the workflow of the button log in as user type A i had the condition "when current user’s user type is “type A”

But when I click on the log in as user type A button nothing happen.

(It works when i don’t use this condition on the log in button but this way i still have the problem that I can use the log in of an user type A pour the log in of the type B user)

Is it the correct way to create specific kind of users ??

Do I need to use this method --> on click event / Account / Create an account for someone else ??

Thanks for the additional help

Did you create the “type of User” as a field of User?

Or are you creating different types of custom data types such as “User type A” or “User type B”

Hello

I think i created it as a field of user

In the data type there is the user.

And inside the user there is:

  • email (created automatically)
  • created date (created automatically)
  • created (created automatically)
    and
  • User Type (text) (that i created) and in default i did not write anything in the box

Do you think that creating it as a field of user is the correct way to restrict the log in possibility

For example I don’t want that the user type A can use his mail and password to log in as user type B

(In my app there is 4 buttons: log in as type A, sign up as type A, log in as type B, sign up as type B)

Thanks for the help

In my app, I’m doing a check on page load to see if user is type A or B. If he is not type A, but he’s trying to get to a type A page, he gets redirected to a page telling him he doesn’t have permission. That’s the “catch” case, in case someone sneaks through. You could also use this logic to determine which types of groups to show on the page. For example, only show the bunny picture if the user is of type B, otherwise show the elephant.

In my app, there are only two types of users so I used a Boolean value instead of a text value. IsUserTypeA = yes/no

2 Likes

Good example. I do the same. On sign up I set the field to user type client & for service providers I have a separate sign up form & set the user type as provider.

On page load I set that if user type is client > navigate to …

Thanks for all the answers so far.

But the problem I have is that I can log in as a type B user with the mail and password of a type A user.

And that’s something I want to avoid.

I tried to make a condition in the button “log in as type A”

I used the condition “and when current’s user’s user type is type A”

But when i am using that nothing happen when I click on the button even if I just created an user type A (with the fields user Type = A)

Have you got a link that we can look at. Maybe copy it over onto the forum app

I will make a copy of this part of my app and put it here as soon as possible

Ok, I think I understand. You have “Student Account,” but those same credentials can log you in as a “Teacher Account.” This behavior is undesirable. Does this describe your situation?

Yes exactly and I can’t find a way to stop this from happening

So this is the copy of the log in sign up part of my app

Normally it is in the header but this time it did not appeared so it’s only on the main page.

So you have to go back to the main page to see if your are logged in or not (The button log out would appear)

Thanks for the help

Haven’t tried this, but could you do a multi-step login flow? It would work like this:

  1. User clicks “login as type A”
  2. They can enter their email address and click “next”
  3. You perform a check to see if that email address is Type A
  4. If it is, you let them enter their password
  5. If it is not, you prevent them from getting any farther.

I can’t think of any reason why this approach wouldn’t work, but again, I haven’t tried it myself.

Well I think the problem is that your conditional on the button is wrong because when you do the condition “Current User’s Type” this is getting the Current User (who is not logged in, generic, and does not have a type).

If you try this in the debugger even with the correct type of User, the debugger will say your type is empty because its getting the Current User not the User you’re trying to login as.

So like others have said above, your better approach would be to allow login of both types on the same page but depending on the Type of the User, display different things or navigate to different pages.

Thanks for the answers.

@peng.o
How would you do it without using Current user ?
If I remember correctly I did not have a lot of choice

How would you do the condition ?

@potentialthings

Thanks for the idea I did not even thought about it. I will try it tomorrow

There are many ways it really depends on what you’re trying to accomplish.

Others above have provided a solution I would take, but another one be to use states.

  1. When Button A is clicked -> Login User -> Set State “type” of index to value Current User’s Type’ value

  2. “Do when” condition, when Current User is logged in and This Page’s type is “A” (or B) -> navigate to page meant for A (or meant for B)