Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Feature: SMS login (and Magic link) is not consitent with Email login #6154

Closed
2 tasks done
Megamannen opened this issue Sep 5, 2023 · 6 comments
Closed
2 tasks done
Assignees
Labels
product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services.

Comments

@Megamannen
Copy link

🔖 Feature description

Right now Create Email Session is the odd duck. Since it doesn't create the user if it doesn't exist.

I'm mainly focusing on the Create Phone session

Possible solution is to accept a "null" userID which can mean "existing user only"

🎤 Pitch

I don't want user registration, but I want to allow signing in with phone or magic link.
Right now that is not possible since the API will create the user if the phone/email doesn't exist.

Probably a fairly common use case?

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@stnguyen90
Copy link
Contributor

stnguyen90 commented Sep 5, 2023

@Megamannen, thanks for raising this issue! 🙏🏼 I would suggest setting the Users Limit to 1:

image

This should prevent new accounts from being created. Then, you can use a server SDK and API Key to create users (which bypasses this limit).

Does that solve your use case?

@stnguyen90 stnguyen90 self-assigned this Sep 5, 2023
@stnguyen90 stnguyen90 added the product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services. label Sep 5, 2023
@Megamannen
Copy link
Author

No, since I don't have any way of knowing the ID/UserId, or am I missing something? Feels the current function can only be used for registration and not login

@ItzNotABug
Copy link
Member

ItzNotABug commented Sep 7, 2023

What the OP means is that createEmailSession doesn't create a new user if one doesn't exist with the provided email address. The OP needs the same behaviour for Phone and Magic-Url Sessions i.e. don't create a new user if the user does not exist in Auth database.

Something like: account. account.createMagicURLSession('[USER_ID]', '[email protected]', false); where false means Don't create an account/register if this user doesn't exist.

@Megamannen
Copy link
Author

Megamannen commented Sep 7, 2023

You are correct in my need. But also remember that it's impossible to provide the matching [USER_ID] when logging in
so account.createMagicURLSession(null, '[email protected]') and account.createPhoneSession(null, '+3800000000') also works :P

@stnguyen90
Copy link
Contributor

@Megamannen, if you set the user limit to some low number and someone calls createMagicURLSession() or createPhoneSession(), but their account (match on email or phone respectively) doesn't exist, they will get an error.

createMagicURLSession() code:

throw new Exception(Exception::USER_COUNT_EXCEEDED);

createPhoneSession() code:

throw new Exception(Exception::USER_COUNT_EXCEEDED);

it's impossible to provide the matching [USER_ID]

You don't need to provide a matching user id when just logging in. that user id parameter is only used during account creation. Otherwise, it's ignored.

@Megamannen
Copy link
Author

You don't need to provide a matching user id when just logging in. that user id parameter is only used during account creation. Otherwise, it's ignored.

In that case it will work in my use case, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services.
Projects
None yet
Development

No branches or pull requests

3 participants