Giter VIP home page Giter VIP logo

Comments (8)

kangmingtay avatar kangmingtay commented on July 17, 2024

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.

nicitaacom avatar nicitaacom commented on July 17, 2024

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.

kangmingtay avatar kangmingtay commented on July 17, 2024

@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.

nicitaacom avatar nicitaacom commented on July 17, 2024

what is the value of...

its value for error code

from gotrue-js.

hf avatar hf commented on July 17, 2024

Please avoid using instanceof for checking errors. Use isAuthError and other helper functions in such cases.

from gotrue-js.

nicitaacom avatar nicitaacom commented on July 17, 2024

Please avoid using instanceof for checking errors. Use isAuthError 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.

therealsujitk avatar therealsujitk commented on July 17, 2024

@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.

therealsujitk avatar therealsujitk commented on July 17, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.