17
Views
4
Comments
Solved
How can a user login using phone number and email for mobile apps?

I want a user to login using a registered email id or phone number(a provision for both) instead of username. How can this be done using the built in user_login provided by outsystems?

And if not possible by user_login, what are the alternatives?

I am attaching an image for more clarity on the use case.

Screenshot20201217120700.png

mvp_badge
MVP
Rank: #19
Solution

Hi Amol,

You'd have to modify the Login screen action of the Login screen to:

  1. Determine if the user typed an email or a phone number
  2. If the user typed a phone number, search for the user with said phone number (add an Aggregate with the User entity and filtering on the phone number) to obtain the corresponding username or email (assuming they are the same).
  3. Use the regular User_Login with the username obtained from either 1. or 2.

Note: This assumes that both the phone number as well as the username/email are unique.

This way you don't have to worry about the details of checking the password before using the System's Login action, you can still rely on the Users' implementation of User_Login to do that for you.

Rank: #89
Solution

Hi Amol,

The alternate way is

Based on Email ID and Phone number you can get user name from User Entity and pass username and password in built in user_login provided by outsystems.

you need to add only one aggregate and add filter based on email and mobile number before doLogin Action.

Hope this will help you.


Regards

Rahul

Rank: #719
Solution

Hi Amol,

There is a built-in action in System module to login a user using its User Identifier.

Before using this, you can first check the email and phone number if it exist in User Entity. If it exist, use the User Identifier of the existing record as an input parameter for the Login Server Action.

Also, to validate the entered password, you can use the ValidatePassword of PlatformPasswordUtils to check if the entered password is same with the stored password in User Entity

Hope this helps,

Regards

Rank: #89
Solution

Hi Amol,

The alternate way is

Based on Email ID and Phone number you can get user name from User Entity and pass username and password in built in user_login provided by outsystems.

you need to add only one aggregate and add filter based on email and mobile number before doLogin Action.

Hope this will help you.


Regards

Rahul

mvp_badge
MVP
Rank: #19
Solution

Hi Amol,

You'd have to modify the Login screen action of the Login screen to:

  1. Determine if the user typed an email or a phone number
  2. If the user typed a phone number, search for the user with said phone number (add an Aggregate with the User entity and filtering on the phone number) to obtain the corresponding username or email (assuming they are the same).
  3. Use the regular User_Login with the username obtained from either 1. or 2.

Note: This assumes that both the phone number as well as the username/email are unique.

This way you don't have to worry about the details of checking the password before using the System's Login action, you can still rely on the Users' implementation of User_Login to do that for you.

Rank: #4639

Thanks for the answers.

All the three solutions work!