After updating email and verifying token, user_metadata still has the old email

Open
#1,670 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
go, javascript, node.js

Research direction

Start at the updateUser and verifyOtp entry points and reproduce the flow with supabase-js 2.42.3 and auth-js 2.63.0. Compare the returned session and auth.users after email verification; done means the new verified email is reflected in user_metadata as well as email and identities.

Written by the indexing model from the issue text.

Description

bug

Bug report

  • 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

After updating a user's email and verifying with OTP token, the user_metadata field isn't updating with the newly verified email.
The email and identities field get correctly updated.
Secure email change is disabled.

To Reproduce

  1. call updateUser({ email: "email2@gmail.com" })
  2. call verifyOtp({ email: "email2@gmail.com", token: token, type: "email_change" })
  3. the session that verifyOtp returns has the old email still in the user_metadata field
  4. in the auth.users table, the user_metadata field still has the old email

Expected behavior

The user_metadata field should be updated with the new email

System information

  • OS: mac
  • Version of supabase-js: "2.42.3"
  • Version of auth-js: "2.63.0"
  • Version of Node.js: "18.13.0"

Additional context

session returned from verifyOtp

{
    "app_metadata": {
        "provider": "email",
        "providers": [
            "email"
        ]
    },
    "aud": "authenticated",
    "confirmation_sent_at": "2024-07-21T00:41:57.424722Z",
    "confirmed_at": "2024-07-21T00:42:04.984262Z",
    "created_at": "2024-07-21T00:41:57.40992Z",
    "email": "email2@gmail.com",
    "email_change_sent_at": "2024-07-21T01:03:21.984546Z",
    "email_confirmed_at": "2024-07-21T00:42:04.984262Z",
    "id": "88e3b62a-54ef-4c49-963d-c09de3a09cd1",
    "identities": [
        {
            "created_at": "2024-07-21T00:41:57.418971Z",
            "email": "email2@gmail.com",
            "id": "88e3b62a-54ef-4c49-963d-c09de3a09cd1",
            "identity_data": [],
            "identity_id": "3fba5840-9614-4066-a38b-8d89e6a7cff6",
            "last_sign_in_at": "2024-07-21T00:41:57.418919Z",
            "provider": "email",
            "updated_at": "2024-07-21T00:55:58.797144Z",
            "user_id": "88e3b62a-54ef-4c49-963d-c09de3a09cd1"
        }
    ],
    "is_anonymous": false,
    "last_sign_in_at": "2024-07-21T01:03:32.004548674Z",
    "phone": "",
    "role": "authenticated",
    "updated_at": "2024-07-21T01:03:32.008945Z",
    "user_metadata": {
        "age": 48,
        "email": "email1@gmail.com",
        "email_verified": false,
        "phone_verified": false,
        "sub": "88e3b62a-54ef-4c49-963d-c09de3a09cd1",
        "username": "ee"
    }
}
Dominant language
Go
Stars
2.6k
Forks
764
Avg merge
5d 3h
Merged PRs (30d)
39

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/auth

All issues in supabase/auth

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.