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

Anonymous Sign In Custom Metadata not working #26566

Closed
housewithbricks opened this issue May 19, 2024 · 2 comments
Closed

Anonymous Sign In Custom Metadata not working #26566

housewithbricks opened this issue May 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@housewithbricks
Copy link

housewithbricks commented May 19, 2024

Bug report

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

Describe the bug

In the javascript documentation for anonymous sign in it shows an option for adding custom metadata to an anonymous sign in.
https://supabase.com/docs/reference/javascript/auth-signinanonymously. This function does not seem to be working for me with the return data from the sign in not including the metadata included.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Sign In anonymous function called from a Next JS server action with supabase ssr client
    const { data, error } = await supabase.auth.signInAnonymously({
      options: {
      data: {
        email: TWData.email,
      }
    }})
  1. print the data
    console.log(data.user, error);
  2. data has no metadata
  id: '8a222158-5669-4ad6-bef9-ba930f63487a',
  aud: 'authenticated',
  role: 'authenticated',
  email: '',
  phone: '',
  last_sign_in_at: '2024-05-18T22:07:54.951782118Z',
  app_metadata: {},
  user_metadata: {},
  identities: [],
  created_at: '2024-05-18T22:07:54.947813Z',
  updated_at: '2024-05-18T22:07:54.954193Z',
  is_anonymous: true
} null```

## Expected behavior

I expect the User to have the email metadata accessible under `data.user.raw_user_metadata`.

## System information

- OS: Windows (WSL)
- Browser (if applies) Chrome
- Version of supabase-js: 2.41.1
- Version of Node.js: 18.17.1


@housewithbricks housewithbricks added the bug Something isn't working label May 19, 2024
@j4w8n
Copy link
Contributor

j4w8n commented May 20, 2024

Can you provide a repro of this? My custom data shows up in both data.user and data.session.user. I'm using supabase-js 2.43.1, but based on release notes I'd think that has nothing to do with it.

const { data, error } = await supabase.auth.signInAnonymously({
  options: {
    data: {
      email: 'stuff',
      handle: 'the'
    }
  }
})
data.user {
  id: 'd40fe803-0e0d-4714-8f9f-7d6035b18e17',
  aud: 'authenticated',
  role: 'authenticated',
  email: '',
  phone: '',
  last_sign_in_at: '2024-05-20T20:04:15.633767296Z',
  app_metadata: {},
  user_metadata: { email: 'stuff', handle: 'the' },
  identities: [],
  created_at: '2024-05-20T20:04:15.628343Z',
  updated_at: '2024-05-20T20:04:15.637134Z',
  is_anonymous: true
}

data.session.user {
  id: 'd40fe803-0e0d-4714-8f9f-7d6035b18e17',
  aud: 'authenticated',
  role: 'authenticated',
  email: '',
  phone: '',
  last_sign_in_at: '2024-05-20T20:04:15.633767296Z',
  app_metadata: {},
  user_metadata: { email: 'stuff', handle: 'the' },
  identities: [],
  created_at: '2024-05-20T20:04:15.628343Z',
  updated_at: '2024-05-20T20:04:15.637134Z',
  is_anonymous: true
}

@housewithbricks
Copy link
Author

Thanks for your help @j4w8n! The ticket can be closed now. It seems like the metadata was not picking up when being passed into sign in, but when I tried static data similar to your example it worked.

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

No branches or pull requests

2 participants