How to handle third-party providers login? #497
-
Hi all, I am really sorry if this sounds like a silly question and probably it is but I do not understand how I am supposed to work with an third-party providers. Let me try to better explain the issue I am facing. I am pretty new to React but I am trying to create a side project with it to better undestand it and I was thinking to use supabase for its database and authentication abilities. I am still experimenting with it but I thought to implement the Bitbucket auth since my team is using it. The fact is that I do not know how to check if the user is logged in or not 😊 Let me explain since I have already found a workaround using Basically I have created an React.useEffect(() => {
setTimeout(() => {
setUser(supabase.auth.user());
}, 2000);
}, [setUser]);
I understand that is more a React question on how to manage something like this but still if someone is able to help me out with this would be simply great. I am not looking for a perfect answer, even a link to an article/tutorial that will help me understand how am I supposed to handle this kind of situation (I open a new window for the login and got redirected back to the same page) would be amazing. Thank you in advance and congratulation for this amazing project, can't wait to use it more and more! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I was checking the Slack clone example and looking at Am I maybe getting closer? 😊 SolutionWell looks like thanks from your examples I've been able to solve my doubts, in order to reference I am adding the React.useEffect(() => {
const { data: authListener } = supabase.auth.onAuthStateChange(
async (event, session) => {
setUser(session?.user ?? null);
}
);
// Cleanup function
return () => {
authListener.unsubscribe();
};
}, [setUser]); I am going to leave open the question just to see if anyone have a better answer and I'll select this in a couple of days. |
Beta Was this translation helpful? Give feedback.
I was checking the Slack clone example and looking at
_app.js
seems to me that I should set thesupabase.auth.onAuthStateChange()
listener.Am I maybe getting closer? 😊
Solution
Well looks like thanks from your examples I've been able to solve my doubts, in order to reference I am adding the
useEffect
that I am using just to give reference to other users that maybe could experience a similar issue.I am going to leave open the question just to …