Add Google Login
This commit is contained in:
@@ -13,6 +13,32 @@ async function checkAuth() {
|
||||
}
|
||||
}
|
||||
|
||||
// Google OAuth Sign In
|
||||
async function signInWithGoogle() {
|
||||
try {
|
||||
setLoading(true);
|
||||
clearMessage();
|
||||
|
||||
const { data, error } = await supabase.auth.signInWithOAuth({
|
||||
provider: 'google',
|
||||
options: {
|
||||
redirectTo: `${window.location.origin}/auth/callback`
|
||||
}
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error('Google OAuth error:', error);
|
||||
showMessage('Fehler bei der Google-Anmeldung: ' + error.message, 'error');
|
||||
}
|
||||
// Note: OAuth redirects the page, so we don't need to handle success here
|
||||
} catch (error) {
|
||||
console.error('Google OAuth error:', error);
|
||||
showMessage('Fehler bei der Google-Anmeldung: ' + error.message, 'error');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle between login and register forms
|
||||
function toggleForm() {
|
||||
const loginForm = document.getElementById('loginForm');
|
||||
@@ -65,6 +91,9 @@ function setLoading(show) {
|
||||
|
||||
// Event Listeners Setup
|
||||
function setupEventListeners() {
|
||||
// Handle Google OAuth
|
||||
document.getElementById('googleSignInBtn').addEventListener('click', signInWithGoogle);
|
||||
|
||||
// Handle login
|
||||
document.getElementById('loginFormElement').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user