auth icon indicating copy to clipboard operation
auth copied to clipboard

signInWithPassword does not return an error code when the login credentials are invalid

Open moralestapia opened this issue 2 years ago • 10 comments

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

Most (all?) other supabase.auth methods return a code property in the error object, if there's any, as documented here.

supabase.auth.signInWithPassword does not, for some reason, and one has to check if the error message property is equal to "Invalid login credentials".

This breaks consistency across the platform and makes people write code that may not be future-proof. If error.message changes then it's gg, while error.code somehow implies a guarantee of stability across time.

To Reproduce

await supabase.auth.signInWithPassword({ email:[some valid email], password:[some invalid password] });

Expected behavior

An error object with a defined code property.

Screenshots

N/A

System information

@supabase/[email protected] @supabase/[email protected]

Node version: 20.15.0

Additional context

I < 3 supabase.

moralestapia avatar Jul 13 '24 19:07 moralestapia

Same with "Email not confirmed".

moralestapia avatar Jul 14 '24 01:07 moralestapia

I got the same issue

seanpham99 avatar Jul 15 '24 06:07 seanpham99

Thanks for opening!

This issue should not be occurring. Please can you update to the latest version of the SSR lib (0.4.0) and supabase-js?

Testing this currently with our auth example and the behaviour is as expected.

const { error } = await supabase.auth.signInWithPassword({
      email,
      password,
    });

correctly throws an error on the server and the client receives a message in the URL.

Let us know how it goes!

encima avatar Jul 15 '24 16:07 encima

The issue is not that an error is not thrown, that does happen, but the error object does not have a code property in (at least) these two cases, unlike all other auth errors.

moralestapia avatar Jul 15 '24 18:07 moralestapia

Btw, updated libs to

@supabase/[email protected] @supabase/[email protected]

Issue is still there.

moralestapia avatar Jul 15 '24 18:07 moralestapia

Ah yes, thank you for the clarification! Transferring to the Auth repo as this seems to be a bug.

encima avatar Jul 16 '24 15:07 encima

jfyi, this is identical to https://github.com/supabase/auth/issues/1631

kangmingtay avatar Jul 19 '24 17:07 kangmingtay

Well then, let's close in favour of tracking it there!

encima avatar Jul 19 '24 19:07 encima

Any update on this? This hard to debug as it occur to some random user

swdevbali avatar May 16 '25 11:05 swdevbali

hello i have the same issue when using a wrong password or non existing email. do you have some update ?

Kleboia avatar Jun 19 '25 12:06 Kleboia