solved Login with user name or email instead of user id

amartins
@amartins
8 years ago
48 posts
I need to login with username or user email and password instead of using user id and password: is there a way to achieve this?

Currently I am using post method with key values pair id and password. If the id is the only way to login, how to get it for a specific user?
updated by @amartins: 05/15/16 04:53:55PM
brian
@brian
8 years ago
10,144 posts
amartins:
I need to login with username or user email and password instead of using user id and password: is there a way to achieve this?

Welcome to Jamroom!

It's best if you can use the ID - this let's the core lookup the account very quickly - otherwise it has to "search" for an account with a matching user name to get the account info. Are you in a situation where you can't store the ID?

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
brian
@brian
8 years ago
10,144 posts
Actually looking at this this would be an easy update - give me a bit here and I can get it supported.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
brian
@brian
8 years ago
10,144 posts
Quick question for you - are you unable to store the user_id that is returned when the account is created? The reason I ask is that other user functionality (updating account, deleting account) need the ID for the update as well.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
amartins
@amartins
8 years ago
48 posts
Thanks! Is because I need it for mobile app and users won't get access to their unique ID.
I need to register users from app also, I tested with Chrome Advanced Rest Client to test creating users, and it keeps creating same user over and over. Do you intent to prevent duplicate users creation? I mean, unique email and unique user name registration?
brian
@brian
8 years ago
10,144 posts
amartins:
Thanks! Is because I need it for mobile app and users won't get access to their unique ID.
I need to register users from app also, I tested with Chrome Advanced Rest Client to test creating users, and it keeps creating same user over and over. Do you intent to prevent duplicate users creation? I mean, unique email and unique user name registration?

It already enforces unique name/email - make sure in the ACP -> Proxima -> Proxima Users -> Global Config that you have selected "Require unique "user_name" and "user_email" fields" - that will enforce the uniqueness on those keys.

When you register a user in your app you will get back an "_id" key - you will want to store that key on the device and use that going forward - that's what I would recommend.

Let me know if that helps.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 02/11/16 12:36:48PM
amartins
@amartins
8 years ago
48 posts
If I create a user I get the id in response, that works fine. But if user is created in website how can he/she login in my app without id? Because they don't know their IDs.
brian
@brian
8 years ago
10,144 posts
amartins:
If I create a user I get the id in response, that works fine. But if user is created in website how can he/she login in my app without id? Because they don't know their IDs.

Ahh - got it - that makes sense. I just pushed out version 1.0.6 of the Proxima User module - you can now sign in by passing a "user_name", "user_email" OR "id" parameter, along with password. The response will now include the "_id" key - so even if they sign in using a user_name or user_email, you will now get the correct _id that should be used on the client.

Let me know if that works for you.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
amartins
@amartins
8 years ago
48 posts
That helped, thanks!
updated by @amartins: 02/11/16 12:55:33PM
amartins
@amartins
8 years ago
48 posts

That's all that we needed. I tested it, working fine! Thanks very much.
I have a question about bridge, should I open new thread?
updated by @amartins: 02/11/16 12:55:10PM
brian
@brian
8 years ago
10,144 posts
amartins:
brian:
Ahh - got it - that makes sense. I just pushed out version 1.0.6 of the Proxima User module - you can now sign in by passing a "user_name", "user_email" OR "id" parameter, along with password. The response will now include the "_id" key - so even if they sign in using a user_name or user_email, you will now get the correct _id that should be used on the client.
Let me know if that works for you.
Hope this helps!
That's all that we needed. I tested it, working fine! Thanks very much.
I have a question about bridge, should I open new thread?

Yep - if you can that would be great.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags