supabase / auth-js

An isomorphic Javascript library for Supabase Auth.
MIT License
356 stars 160 forks source link

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

Closed mb21 closed 7 months ago

mb21 commented 10 months ago

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

Additional context

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

mb21 commented 10 months ago

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

mb21 commented 10 months ago

Or would a pull request fixing this be merged?

JJAHMEDAMER commented 8 months ago

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 commented 7 months ago

@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: https://github.com/supabase/gotrue-js/pull/848

mb21 commented 7 months ago

@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?

mb21 commented 7 months ago

@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 commented 7 months ago

@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 commented 6 months ago

@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