Repository navigation
fix: add create_user field to otp endpoint - #318
Conversation
|
@dthyresson pointed out that it's possible for the |
Or @kangmingtay perhaps instead of a GoTrue config, this rule could be part of Allow/deny user rules. For examlple:
So instead of a if disable sign ups or a config on magic link — include a rule where there is a method and a rule. For magic link on sign up check if user exists. It is still configuration but less of an envar boolean and more rule based. Perhaps too involved in near term and a setting will suffice. |
|
I'm still uncomfortable with this being completely a client-side controlled flag
Since the Then here the api changes to pass a boolean to create the user or not -- but there's nothing really enforcing the "rule" but rather it is an option. I guess the question is: is this a rule that enforces users cannot be created for OTP signups or rather this is an option available when signing up? If the user is not to be created, ma then perhaps signups are just disabled instead? And then admins create accounts and then users simply sign in? I'd be concerned that if the rulers around this change, then the api has breaking changes rather than enforcing new rules about how users get created, sign in/up and the process. This seems to be a stop-gap solution for a bigger question: how to whitelist user profiles to ensure only certain individuals can access/use an app. Auth0 handles something similar with its Rule callbacks that can sit in between sign in and ups and do verification and then stop auth from happening. This is used to only allow signups for accounts with certain email domains -- or lookup the account from an approved list. |
Nope, this flag is not to safeguard against those cases, it's merely an option for developers to disable automatic creation of users when using otps. If the developers want to restrict signups, then should use the
The user can be created, just not automatically via the otp endpoint. This will enable developers to separate the sign-up and login flows on the client-side where you have
Hmm, i don't really view it as a breaking change since we are adding an optional flag which defaults to the original behaviour if it's not set. |
|
|
||
| One-Time-Password. Will deliver a magiclink or sms otp to the user depending on whether the request body contains an "email" or "phone" key. | ||
|
|
||
| If `"create_user": true`, user will not be automatically signed up if the user doesn't exist. |
There was a problem hiding this comment.
is this right? If create_user == true, then user will not be signed up? seems counter intuitive
There was a problem hiding this comment.
ah my bad. this is a typo error, it should be if create_user == true, then the user will be automatically signed up
| ```js | ||
| { | ||
| "phone": "12345678" // follows the E.164 format | ||
| "create_user": true |
There was a problem hiding this comment.
I read the discussion but still a bit confused about the use case, sorry.
What is the default behavior if omitted?
And the dev still has the ability to prevent signups on these endpoints via some config if they want to enforce login only, right?
There was a problem hiding this comment.
if omitted, the default behaviour would be the current behaviour - which is that the user will be automatically signed up if they don't have an existing account, and logged in if they do.
There was a problem hiding this comment.
This flag isn't to restrict signups globally in their app. I think the use case here is for developers to have 2 separate flows - one for sign-up and one for sign-in when using magiclinks / otps.
|
🎉 This PR is included in version 2.4.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
* feat: add create user param to sign in ref: supabase/auth#318 * 'Refactored by Sourcery' (#76) Co-authored-by: Sourcery AI <> * chore: format code * chore: format code Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
|
I wanted to implement this but I am getting a typescript error when I try to add the "create_user" flag to my signIn function: "Argument of type '{ email: string; create_user: boolean; }' is not assignable to parameter of type 'UserCredentials'. Here's my code: async function signIn(email: string) {
const { error } = await supabase.auth.signIn({ email, create_user: false })
return { error }
} |
* fix: add no_signup field to otp endpoint * docs: update readme * refactor: rename no_signup to create_user * test: add otp tests * docs: update readme * fix: unhandled otp error
What kind of change does this PR introduce?
What is the new behavior?
Both will result in a bad request with a message of "Signups not allowed for otp"
Todo