Fix login flows
This commit is contained in:
@@ -211,8 +211,8 @@
|
||||
<span>or</span>
|
||||
</div>
|
||||
|
||||
<a href="/auth/google" class="btn btn-google">Google</a>
|
||||
<a href="/auth/instagram" class="btn btn-instagram">Instagram</a>
|
||||
<a href="/auth/google" class="btn btn-google" id="googleBtn">Google</a>
|
||||
<a href="/auth/instagram" class="btn btn-instagram" id="instagramBtn">Instagram</a>
|
||||
|
||||
<div class="toggle-form">
|
||||
<a href="#" onclick="toggleForm()">Don't have an account? Register</a>
|
||||
@@ -240,8 +240,8 @@
|
||||
<span>or</span>
|
||||
</div>
|
||||
|
||||
<a href="/auth/google" class="btn btn-google">Sign up with Google</a>
|
||||
<a href="/auth/instagram" class="btn btn-instagram">Sign up with Instagram</a>
|
||||
<a href="/auth/google" class="btn btn-google" id="googleRegBtn">Sign up with Google</a>
|
||||
<a href="/auth/instagram" class="btn btn-instagram" id="instagramRegBtn">Sign up with Instagram</a>
|
||||
|
||||
<div class="toggle-form">
|
||||
<a href="#" onclick="toggleForm()">Already have an account? Login</a>
|
||||
@@ -292,7 +292,18 @@
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
window.location.href = '/dashboard';
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const redirectUrl = urlParams.get('redirect');
|
||||
if (redirectUrl) {
|
||||
const cityMatch = redirectUrl.match(/\/city\/([^\/]+)/);
|
||||
if (cityMatch) {
|
||||
window.location.href = `/city/${cityMatch[1]}/dashboard`;
|
||||
} else {
|
||||
window.location.href = '/dashboard';
|
||||
}
|
||||
} else {
|
||||
window.location.href = '/dashboard';
|
||||
}
|
||||
} else {
|
||||
showMessage('Invalid username or password');
|
||||
}
|
||||
@@ -321,7 +332,18 @@
|
||||
if (response.ok) {
|
||||
showMessage('Registration successful! Redirecting...', 'success');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/dashboard';
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const redirectUrl = urlParams.get('redirect');
|
||||
if (redirectUrl) {
|
||||
const cityMatch = redirectUrl.match(/\/city\/([^\/]+)/);
|
||||
if (cityMatch) {
|
||||
window.location.href = `/city/${cityMatch[1]}/dashboard`;
|
||||
} else {
|
||||
window.location.href = '/dashboard';
|
||||
}
|
||||
} else {
|
||||
window.location.href = '/dashboard';
|
||||
}
|
||||
}, 1500);
|
||||
} else {
|
||||
showMessage(result.error || 'Registration failed');
|
||||
@@ -330,6 +352,20 @@
|
||||
showMessage('Registration failed. Please try again.');
|
||||
}
|
||||
});
|
||||
|
||||
// Update OAuth links with redirect parameter
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const redirectUrl = urlParams.get('redirect');
|
||||
|
||||
if (redirectUrl) {
|
||||
const encodedRedirect = encodeURIComponent(redirectUrl);
|
||||
document.getElementById('googleBtn').href = `/auth/google?redirect=${encodedRedirect}`;
|
||||
document.getElementById('instagramBtn').href = `/auth/instagram?redirect=${encodedRedirect}`;
|
||||
document.getElementById('googleRegBtn').href = `/auth/google?redirect=${encodedRedirect}`;
|
||||
document.getElementById('instagramRegBtn').href = `/auth/instagram?redirect=${encodedRedirect}`;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user