auth-js
auth-js copied to clipboard
updateUserById - user_id must be an UUID
Bug report
Describe the bug
invoke functionuser_id must be an UUID return user_id must be an UUID
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Create a file "test.js" and copy this code:
const {createClient} = require('@supabase/supabase-js')
require('dotenv').config()
const options = {
schema: 'public',
headers: {},
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: true
}
const supabase = createClient("http://localhost:8000", process.env.SERVICE_ROLE_KEY, options)
async function createUsers(){
const { data: admin, errorADMIN } = await supabase.auth.api.createUser({
email: '[email protected]',
password: 'password',
data: { name: 'Test Admin' }
})
if(!errorADMIN){
console.log('> User: [email protected] - Created',admin)
const test = await supabase.auth.api.updateUserById({
uid: admin.id,
attributes: { email_confirm: true },
})
console.log('##### TEST', test)
}else{
console.log(errorADMIN)
}
const { data: user, errorUSER } = await supabase.auth.api.createUser({
email: '[email protected]',
password: 'password',
data: { name: 'Test User' },
attributes: { email_confirm: true },
})
if(!errorUSER){
console.log('> User: [email protected] - Created',user)
const test2 = await supabase.auth.api.updateUserById({
uid: user.id,
attributes: { email_confirm: true },
})
console.log('##### TEST', test2)
}else{
console.log(errorUSER)
}
}
createUsers()
Replace fix env / urls to be in the same page with ur setup
Expected behavior
I expect to update the user with the uid returned by createUser function
Screenshots

System information
- OS: Windows 11
- Version of supabase-js: 1.30
- Version of Node.js: 14
I'm having the same issue here.
+1 also getting the same error
Solution I am using (seems to work), if you are wanting to create a user and have them confirmed without the user having to do anything. Instead of createUser and updateUserById, I just called auth.signUp from the server with their email and password. That seems to work.
Solution I am using (seems to work), if you are wanting to create a user and have them confirmed without the user having to do anything. Instead of createUser and updateUserById, I just called auth.signUp from the server with their email and password. That seems to work.
Already knew but... are different concepts, the signUp will create the user and set the supabase istance with the user auth, the createUser go to create the user without set the auth
+1 having this issue as well
+1 having this issue as well
@kiwicopple this is the right repository for this bug?
Hey @WilliamFalci, @limmidy, @impactvelocity, @ngerritsen, this isn't a bug with the client library. Based on the example @WilliamFalci provided above, the uid is being passed incorrectly in updateUserById. See the updateUserById method.
// Incorrect
const test = await supabase.auth.api.updateUserById({
uid: user.id,
attributes: { email_confirm: true },
})
// Correct
const test = await supabase.auth.api.updateUserById(user.id, {
email_confirm: true,
})
Will be closing this issue since it's not an issue with the client library. Please let me know if you guys still have any questions regarding this issue.