Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth: Change DX of user management #20

Closed
thorwebdev opened this issue Aug 25, 2020 · 3 comments · Fixed by #50
Closed

Auth: Change DX of user management #20

thorwebdev opened this issue Aug 25, 2020 · 3 comments · Fixed by #50
Labels
enhancement New feature or request

Comments

@thorwebdev
Copy link
Member

Feature request

Is your feature request related to a problem? Please describe.

As it stands today, you have to do

try {
const {
  body: { user },
} = await supabase.auth.signup(
  'someone@email.com',
  'password'
)
...

To get the user object, and

...} catch (error) {
      console.log('Error message:', error.response.body.error_description);
    } 

to get to the error message.

Describe the solution you'd like

my preferred DX would be

const { error, user } = await supabase.auth.signup(
  'someone@email.com',
  'password'
);
if (error) alert(error);

However, I know that @awalias is a big fan of returning the whole response object, which I personally find rather distracting. Maybe we can do something like

const { error, user, raw_response } = await supabase.auth.signup(
  'someone@email.com',
  'password'
);
if (error) alert(error);

To give folks the option to access the raw object, but not overload folks who don't care about most of the stuff in the raw response. Wdyt? This probably warrants a new issue?

Describe alternatives you've considered

Solve via documentation? Not ideal IMO.

Additional context

Relates to supabase/supabase#143

@thorwebdev thorwebdev added the enhancement New feature or request label Aug 25, 2020
@awalias
Copy link
Member

awalias commented Aug 25, 2020

as mentioned by @kiwicopple will also want to revisit signup(email, password) to allow different types of signup.

and also wrapping https://github.com/netlify/gotrue-js - note here that we may have to fork initially since our own gotrue api has diverged on some details (such as how email/password are passed in body as opposed to query params etc.)

@kiwicopple
Copy link
Member

See ongoing PR here for GoTrue changes: supabase/auth-js#1

Should we shift the convo over there and roll the changes into our gotrue-js fork?

@kiwicopple
Copy link
Member

kiwicopple added a commit that referenced this issue Nov 2, 2020

- Fixes #32 Major DX change: response and error handling
- Fixes #49 When no `supabaseKey` is passed in it throws an error
- Fixes #31 chore: set up semantic releases
- Fixes #15 `supabase.auth.logout()` throws "Invalid user" error.
- Fixes #20 Auth: Change DX of user management
- Fixes #30 Supabase auth interface missing informiation
- Fixes supabase/supabase#147 supabase/supabase#147
- Partial fix for supabase/realtime-js#53  - if there is no token provided. The error needs to be caught at a socket level.
- Adds magic links


## BREAKING CHANGES

- See all breaking changes in RELEASE.md v1.0.0
- Errors are now returned and not thrown
- Auth now uses `@supabase/gotrue-js` interface
- `supabase.getSubscriptions()` only returns open subscriptions



* Updates the config

* chore: Migrates the basic outline to TS

* Adds a simple example showing how it can be used.

* chore: Moves tests to jest

* chore: Adds semantic releases

* Moves the subscription into it's own class

* Updates the todo readme with simple instructions

* Updates installs

* Revverts commented code - sorry for the spam

* docs: adds JSDoc to some functions

* chore: Adds a function for backwards compat

* chore: migrates the client to SupabaseClient

* This change attempts to make the naming conventions the same as Thor's previously

* Updates GoTrue to latest version

* Adds generic type to the from, and updates the name of the query builder

* Updates to latest versions of all packages

* Updates the example to make sure it's working

* Refactor SupabaseQueryBuilder

* Adds prettier hook

* Add TypeScript next.js example.

* Declutter SupabaseClient and make work with gotrue-js changes.

* Bumps the GoTrue version

* Bumps postgrest to include the types

* Temporarily adds the spec so that I can use it in our docs

* Update examples and add resetPassword.

* Bump gotrue-js version.

* Update lockfile.

* Add auth magic link capabilities.

* Gotrue-js user and session method updates.

* chore: Adds release notes

Co-authored-by: Thorsten Schaeff <thorsten.schaeff@gmail.com>
Co-authored-by: Thor 雷神 Schaeff <5748289+thorwebdev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants