Weird issue with sessions using supabase python & django
I'm creating a web app using django and supabase for as the backend. My users login using email and password. However, the session created after login seems to be being shared across different browsers and machines. I think I'm doing or understanding something wrong because I'm expecting each logged in user to have a separate session. Right now, what happens is that when I log in a user, when I open the website on a totally different machine and I see that user is logged in on that other machine too. Super weird.
What am I missing here? Here's my simple login code for my view:
def login(request):
supabase: Client = Client(supabase_url, supabase_key)
if request.method == 'POST':
email = request.POST.get('email')
password = request.POST.get('password')
print(email)
print(password)
data = supabase.auth.sign_in_with_password({"email": email, "password": password})
user = data.user
if user:
res = supabase.auth.get_session()
return redirect('/') # Replace with the name of your success view
else:
messages.error(request, "Login failed. Please check your email and password.")
user_session = supabase.auth.get_session()
if user_session is None:
# If not a POST request or login failed, render the login form again
return render(request, 'login.html')
else:
return redirect('/')
What am I missing here? Here's my simple login code for my view:
def login(request):
supabase: Client = Client(supabase_url, supabase_key)
if request.method == 'POST':
email = request.POST.get('email')
password = request.POST.get('password')
print(email)
print(password)
data = supabase.auth.sign_in_with_password({"email": email, "password": password})
user = data.user
if user:
res = supabase.auth.get_session()
return redirect('/') # Replace with the name of your success view
else:
messages.error(request, "Login failed. Please check your email and password.")
user_session = supabase.auth.get_session()
if user_session is None:
# If not a POST request or login failed, render the login form again
return render(request, 'login.html')
else:
return redirect('/')