fix auth
This commit is contained in:
@@ -19,10 +19,27 @@ def login_oauth(provider):
|
||||
@bp.route("/callback/<provider>")
|
||||
def callback(provider):
|
||||
"""Handle OAuth callback from specified provider."""
|
||||
from flask import redirect, make_response
|
||||
|
||||
try:
|
||||
return auth_service.handle_callback(provider)
|
||||
auth_response = auth_service.handle_callback(provider)
|
||||
|
||||
# If successful, redirect to frontend dashboard with cookies
|
||||
if auth_response.status_code == 200:
|
||||
redirect_response = make_response(redirect("http://localhost:3000/dashboard"))
|
||||
|
||||
# Copy all cookies from the auth response
|
||||
for cookie in auth_response.headers.getlist('Set-Cookie'):
|
||||
redirect_response.headers.add('Set-Cookie', cookie)
|
||||
|
||||
return redirect_response
|
||||
else:
|
||||
# If there was an error, redirect to login with error
|
||||
return redirect("http://localhost:3000/login?error=oauth_failed")
|
||||
|
||||
except Exception as e:
|
||||
return {"error": str(e)}, 400
|
||||
error_msg = str(e).replace(' ', '_').replace('"', '')
|
||||
return redirect(f"http://localhost:3000/login?error={error_msg}")
|
||||
|
||||
|
||||
@bp.route("/providers")
|
||||
|
||||
Reference in New Issue
Block a user