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

signInWithPassword ignores options.data instead of writing it to user_metadata #811

Closed
2 tasks done
mb21 opened this issue Nov 9, 2023 · 8 comments · Fixed by #848
Closed
2 tasks done

signInWithPassword ignores options.data instead of writing it to user_metadata #811

mb21 opened this issue Nov 9, 2023 · 8 comments · Fixed by #848
Labels
bug Something isn't working

Comments

@mb21
Copy link

mb21 commented Nov 9, 2023

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

signInWithPassword ignores the options.data field, even though the TypeScript definitions list options.data as a supported field – at least in the case where you provide a phone number.

To Reproduce

Call supabase.auth.signInWithPassword({ phone, password, options: { data } }).

Expected behavior

options.data should be persisted in auth.users.user_metadata.

Ideally, this should also work for the case where you provide email instead of phone.

System information

  • Version of supabase-js: 1.110.1
  • Version of Node.js: 18.17.1

Additional context

Related question: https://github.com/orgs/supabase/discussions/8873

@mb21 mb21 added the bug Something isn't working label Nov 9, 2023
@mb21
Copy link
Author

mb21 commented Nov 23, 2023

Uhm... any chance this will be resolved at some point? Or are we better off using the REST API directly?

@mb21
Copy link
Author

mb21 commented Nov 28, 2023

Or would a pull request fixing this be merged?

@JJAHMEDAMER
Copy link

JJAHMEDAMER commented Jan 11, 2024

Is this an issue with the type definition, it seems like the data object exists on the second type with the phone number

  | {
      /** The user's email address. */
      email: string
      /** The user's password. */
      password: string
      options?: {
        /** Verification token received when the user completes the captcha on the site. */
        captchaToken?: string
      }
    }
  | {
      /** The user's phone number. */
      phone: string
      /** The user's password. */
      password: string
      options?: {
        /**
         * A custom data object to store the user's metadata. This maps to the `auth.users.user_metadata` column.
         *
         * The `data` should be a JSON object that includes user-specific info, such as their first and last name.
         */
        data?: object
        /** Verification token received when the user completes the captcha on the site. */
        captchaToken?: string
      }
    }

@kangmingtay
Copy link
Member

@mb21 @JJAHMEDAMER apologies for the oversight, this is an issue with the type definition and i've just put up a PR to fix this: #848

@mb21
Copy link
Author

mb21 commented Feb 6, 2024

@kangmingtay thanks for taking a look at this! My preferred outcome would of course have been that the data is written to user_metadata, not that the type definition is removed. Would this be considered a feature request? Would it be merged if I made a PR?

kangmingtay added a commit that referenced this issue Feb 7, 2024
## What kind of change does this PR introduce?
* Fixes #811
@mb21
Copy link
Author

mb21 commented Feb 8, 2024

@kangmingtay and @hf you're working for supabase, right? Could you please answer my question(s) about whether a PR would be accepted to save signInWithPassword's options.data argument to user_metadata? Or should I open a new issue with this feature request?

@Giasinit
Copy link

@mb21 Hi, may you share your solution?
Anyway.. they removed the option to pass data when you sign in..
so i think we need to use a procedure/function in order to sign in..

@mb21
Copy link
Author

mb21 commented Mar 27, 2024

@Giasinit I haven't actually coded anything and am not going to unless somebody from supabase gives an indication that it might be merged. But as unresponsive as they have been it's unclear to me whether supabase auth is actively developed. Therefore we're looking to switch to https://lucia-auth.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants