GHOST
09/08/2021, 7:05 PMjs
supabase.auth.onAuthStateChange((event, session) => {
const data = session?.user;
switch (event) {
case 'SIGNED_IN':
// Set user as signed in, data is the user data
break;
case 'SIGNED_OUT':
// Set user as signed out
break;
}
});
Then in your login function you have
js
const signIn = () =>
supabase.auth.signIn(
{
provider: 'discord',
}
);
basically what happens is you call the signIn with discord which redirects to discord, when the user is redirected back to your app supabase should catch that and emit the event and you can respond to that
hopefully they improve the design in the next version of supabase-js to have a popup meaning you would be able to do what they say in the docs
for email and password the await supabase ... will workGHOST
09/08/2021, 7:05 PMymahmo
09/08/2021, 7:45 PMstibbs
09/08/2021, 8:41 PMawait
sign in with external providers thoughstibbs
09/08/2021, 8:43 PMstibbs
09/08/2021, 8:49 PMKylar
09/08/2021, 9:10 PMGHOST
09/08/2021, 9:15 PMstibbs
09/08/2021, 9:22 PMstibbs
09/08/2021, 9:23 PMstibbs
09/08/2021, 9:24 PMstibbs
09/08/2021, 9:25 PMScott P
09/09/2021, 1:04 AMredirect_uri
provided in the dashboard
From there, it is up to the code on how it proceeds.
If the user has already authed previously with that same provider, Supabase won't direct the user to auth again unless the third party provider requires it (e.g. if the user has removed that applications access from the account they have with the third party provider)Deleted User
09/09/2021, 2:47 AM.throwOnError()
this way?
I'm using this: js
const { data: supabaseData } = await supabase
.from('cases')
.select('caseNumber')
.order('caseNumber', { ascending: false })
.limit(1)
.single()
.throwOnError();
and it errors on throwOnError()
saying js
Property 'throwOnError' does not exist on type 'PromiseLike<PostgrestSingleResponse<any>>'.ts(2339)
I'm also using Typescript. Thanks in advanceScott P
09/09/2021, 3:00 AM.catch()
on the end, and throw the error that way if you need to. Alternatively, checking if errors is truthy and throwing that way is another option.Deleted User
09/09/2021, 3:02 AMdavlaha
09/09/2021, 5:10 PMgoogle oauth
the documentation seems to be limited herestibbs
09/10/2021, 2:26 AMstibbs
09/10/2021, 4:05 AMNeucoas
09/10/2021, 12:52 PMpg
?akaban
09/10/2021, 2:26 PMPostgresFilterBuilder
object that contains all of the information of the request but the actual request will only be made when I await for this object.
This is maybe a javascript classic thing to do but it seems strange that I have an object that can also behaves like a promise when we await.
Can someone show me an example of supabase request without await
? This could help me understand I think, thanks a lot !jcarenza
09/10/2021, 2:37 PMawait
like:
supabase.auth.signIn().then()
akaban
09/10/2021, 2:43 PMthen
and it works. Thanks a lot !
JS-related question, does that mean that the real supabase promise in only fired when we call then on it?Scott P
09/10/2021, 2:47 PM.signIn()
, but you won't receive the response back in your code, as it's not something that runs in sync.
It's fairly common for code which should be run as async/a promise to return an object if you console.log()
it, unless you await
or .then()
it.
Remember, that the primitive types in JS are string, number, bigint, boolean, symbol, null and undefined. Everything else is an object (even arrays).jcarenza
09/10/2021, 2:48 PMakaban
09/10/2021, 2:49 PMinsert
and not signin
the real insert would only happen when I would await for the PostgresFilterBuilder
so it looks like the request is not fired without awaitingakaban
09/10/2021, 2:49 PMScott P
09/10/2021, 2:50 PMScott P
09/10/2021, 2:50 PMSubh
09/10/2021, 5:54 PM