Comments (8)
Hi @nicitaacom, it appears that the link to your github repo is broken, can you please paste the correct link to the code snippet so that we can investigate further?
from gotrue-js.
can you please paste the correct link to the code snippet
I corrected it - thank you for your interest in this issue
from gotrue-js.
@nicitaacom thanks for updating the link! what is the value of error as { code?: string })?.code
when you do:
if ((error as { code?: string })?.code === "23505") {
displayResponseMessage(<p className="text-danger">This user already exists</p>)
}
from gotrue-js.
what is the value of...
its value for error code
from gotrue-js.
Please avoid using instanceof
for checking errors. Use isAuthError
and other helper functions in such cases.
from gotrue-js.
Please avoid using
instanceof
for checking errors. UseisAuthError
and other helper functions in such cases.
Provide code please
Do you mean instead
if (error instanceof AuthError) {
use
if (error instanceof isAuthError) {
from gotrue-js.
@nicitaacom he meant use this instead.
if (isAuthError(error)) {
...
}
As for customising error messages for Auth, I don't think it's possible as of now. The closest thing I could find was Auth Hooks, but I don't think this does what you'd want, plus it doesn't come free.
from gotrue-js.
@kangmingtay this would be a nice feature though (not sure if it's already open somewhere).
Currently for Supabase API calls, you can throw exceptions using trigger functions to add validations (Ex: If a user tries to add an invalid record, you can create a trigger to check the record and raise an exception). ~ More info
I tested this by inserting data into a public table, and I got a proper error message and status code (the same as the one's I set). However, this doesn't work for auth requests (Ex: supabaseClient.auth.signUp()
). I tried creating a trigger that raises an exception on auth.users
insert, however it gives back a generic error message "Database error saving new user". This was probably done for security reasons, but it would be nice to somehow add custom error messages.
I'm currently planning to write a Deno wrapper function around the signUpWithPassword()
function to handle validations.
from gotrue-js.
Related Issues (20)
- "User with this email not found" error when using generateLink HOT 9
- Google OAuth doesn't work in Safari with next-js-auth-helpers HOT 1
- New, unsigned in user can not be deleted from supabase console. HOT 1
- [email protected] breaks client auth with edge functions HOT 15
- New error code is missing in error object
- user object warning logged, even when not touching `session.user` HOT 34
- Security and performance risk with `getUser` and `getSession` HOT 6
- Global supabase.auth.signOut() doesn't fire the "SIGNED_OUT" event for onAuthStateChange in other instances where a user is logged in HOT 5
- Current session lost when auth function call fails HOT 1
- Impossible to check null session without getSession warning HOT 9
- `getSession` should validate the session with the JWT_SECRET HOT 2
- getAuthenticatorAssuranceLevel() triggers "getSession() could be insecure" warnings HOT 3
- PKCE flow issue with other than supabase `code` query in URL
- Still having getSession warning whenever _saveSession is called HOT 7
- Session from session_id claim in JWT does not exist HOT 1
- Token has expired or is invalid or duplicate key value violates unique constraint "refresh_tokens_pkey" HOT 1
- NPM version tagged as latest still 2.62.2 HOT 1
- Client-side Supabase Auth Session/Access Token Expires Too Soon HOT 3
- No connection to my local hosted supbabase/auth instance on newer versions HOT 1
- `errorCode` is `undefined` because `data.error` is not processed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gotrue-js.