Skip to content

Commit a91d069

Browse files
Fix email verification link handling for web and Electron
1 parent 66e1201 commit a91d069

4 files changed

Lines changed: 49 additions & 61 deletions

File tree

index.html

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ <h1 id="title">Bei Twitter anmelden</h1>
215215
"auth/missing-password": "Bitte ein Passwort eingeben.",
216216
"auth/invalid-credential": "Login fehlgeschlagen. Bitte Daten pruefen.",
217217
"auth/email-already-in-use": "Diese E-Mail wird bereits verwendet.",
218-
"auth/weak-password": "Passwort ist zu schwach (mind. 8 Zeichen)."
218+
"auth/weak-password": "Passwort ist zu schwach (mind. 8 Zeichen).",
219+
"auth/too-many-requests": "Zu viele Versuche. Bitte spaeter erneut versuchen.",
220+
"auth/unauthorized-domain": "Domain nicht autorisiert. Bitte Firebase Authorized Domains pruefen.",
221+
"auth/operation-not-allowed": "E-Mail/Passwort Login ist in Firebase nicht aktiviert."
219222
};
220223
return map[code] || "Aktion fehlgeschlagen. Bitte erneut versuchen.";
221224
}
@@ -241,12 +244,16 @@ <h1 id="title">Bei Twitter anmelden</h1>
241244
} else {
242245
credential = await createUserWithEmailAndPassword(auth, email, pass);
243246
await ensureProfile(credential.user);
244-
245-
// Auto-bypass: Kein sendEmailVerification (Firebase Permission Issue)
246-
const { getFirestore, doc, updateDoc } = await import("https://www.gstatic.com/firebasejs/10.7.1/firebase-firestore.js");
247-
const db = getFirestore(app);
248-
await updateDoc(doc(db, "users", credential.user.uid), { emailBypass: true });
249-
statusEl.textContent = "✓ Account erstellt - Weiterleitung...";
247+
248+
const verifyBase = window.location.origin.startsWith("http")
249+
? window.location.origin
250+
: "https://alexgaming.is-a.dev";
251+
const actionCodeSettings = {
252+
url: `${verifyBase}/verify-email/`,
253+
handleCodeInApp: false
254+
};
255+
await sendEmailVerification(credential.user, actionCodeSettings);
256+
statusEl.textContent = "Verifizierungs-E-Mail wurde gesendet. Bitte Postfach pruefen.";
250257
statusEl.style.color = "#1da1f2";
251258
}
252259

nexnet/register/index.html

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ <h1 class="orbitron text-2xl font-black tracking-[0.2em] text-white">NEX<span st
8888
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";
8989
import { getAuth, createUserWithEmailAndPassword, onAuthStateChanged, sendEmailVerification }
9090
from "https://www.gstatic.com/firebasejs/10.7.1/firebase-auth.js";
91-
import { getFirestore, doc, setDoc, serverTimestamp, query, where, collection, getDocs, updateDoc }
91+
import { getFirestore, doc, setDoc, serverTimestamp, query, where, collection, getDocs }
9292
from "https://www.gstatic.com/firebasejs/10.7.1/firebase-firestore.js";
9393
import { firebaseConfig } from "/js/firebase-config.js";
9494

@@ -168,24 +168,14 @@ <h1 class="orbitron text-2xl font-black tracking-[0.2em] text-white">NEX<span st
168168
createdAt: serverTimestamp()
169169
});
170170

171-
// Send e-mail verification link before redirecting
172-
// Check if dev/localhost environment
173-
const isDev = window.location.hostname === "localhost" ||
174-
window.location.hostname === "127.0.0.1" ||
175-
window.location.protocol === "file:";
176-
177-
if (!isDev) {
178-
try {
179-
await sendEmailVerification(credential.user);
180-
} catch (emailErr) {
181-
// Fallback when email fails
182-
console.warn("Email send failed, using bypass:", emailErr.message);
183-
await updateDoc(doc(db, "users", uid), { emailBypass: true });
184-
}
185-
} else {
186-
// Dev mode: auto-bypass
187-
await updateDoc(doc(db, "users", uid), { emailBypass: true });
188-
}
171+
const verifyBase = window.location.origin.startsWith("http")
172+
? window.location.origin
173+
: "https://alexgaming.is-a.dev";
174+
const actionCodeSettings = {
175+
url: `${verifyBase}/verify-email/`,
176+
handleCodeInApp: false
177+
};
178+
await sendEmailVerification(credential.user, actionCodeSettings);
189179

190180
window.location.replace("/verify-email/");
191181
} catch (err) {

nexnet/verify-email/index.html

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -176,37 +176,20 @@ <h2 class="text-lg font-bold text-white mb-3">Confirm Your Identity Address</h2>
176176
if (!user) return;
177177

178178
try {
179-
// Check if dev/localhost environment
180-
const isDev = window.location.hostname === "localhost" ||
181-
window.location.hostname === "127.0.0.1" ||
182-
window.location.protocol === "file:";
183-
184-
if (isDev) {
185-
statusEl.textContent = "🔧 Dev-Mode: E-Mail verification skipped.";
186-
statusEl.style.color = 'var(--accent)';
187-
statusEl.classList.remove('hidden');
188-
await updateDoc(doc(db, 'users', user.uid), { emailBypass: true });
189-
setTimeout(() => { window.location.replace("/home/"); }, 1000);
190-
return;
191-
}
192-
193-
try {
194-
await sendEmailVerification(user);
195-
resendCooldown = true;
196-
statusEl.textContent = "✓ Verification e-mail resent. Please check your inbox.";
197-
statusEl.style.color = 'var(--accent)';
198-
statusEl.classList.remove('hidden');
199-
// Allow resending again after 60 seconds
200-
setTimeout(() => { resendCooldown = false; }, 60000);
201-
} catch (emailErr) {
202-
// Fallback when email fails
203-
console.warn("Email send failed, using bypass:", emailErr.message);
204-
statusEl.textContent = "⚠️ E-Mail could not be sent, using bypass...";
205-
statusEl.style.color = '#ff9800';
206-
statusEl.classList.remove('hidden');
207-
await updateDoc(doc(db, 'users', user.uid), { emailBypass: true });
208-
setTimeout(() => { window.location.replace("/home/"); }, 1500);
209-
}
179+
const verifyBase = window.location.origin.startsWith("http")
180+
? window.location.origin
181+
: "https://alexgaming.is-a.dev";
182+
const actionCodeSettings = {
183+
url: `${verifyBase}/verify-email/`,
184+
handleCodeInApp: false
185+
};
186+
await sendEmailVerification(user, actionCodeSettings);
187+
resendCooldown = true;
188+
statusEl.textContent = "✓ Verification e-mail resent. Please check your inbox.";
189+
statusEl.style.color = 'var(--accent)';
190+
statusEl.classList.remove('hidden');
191+
// Allow resending again after 60 seconds
192+
setTimeout(() => { resendCooldown = false; }, 60000);
210193
} catch (err) {
211194
statusEl.textContent = "Error: " + err.message;
212195
statusEl.style.color = '#ff4d6d';

verify-email/index.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,21 @@ <h1>E-Mail bestaetigen</h1>
141141
if (!user) return;
142142

143143
try {
144-
statusEl.textContent = "✓ Verifikation bestätigt - weiterleiten...";
144+
const verifyBase = window.location.origin.startsWith("http")
145+
? window.location.origin
146+
: "https://alexgaming.is-a.dev";
147+
const actionCodeSettings = {
148+
url: `${verifyBase}/verify-email/`,
149+
handleCodeInApp: false
150+
};
151+
152+
await sendEmailVerification(user, actionCodeSettings);
153+
statusEl.textContent = "Verifizierungs-E-Mail wurde erneut gesendet.";
145154
statusEl.style.color = "#1da1f2";
146155
cooldown = true;
147-
await updateDoc(doc(db, "users", user.uid), { emailBypass: true });
148-
setTimeout(() => { window.location.href = "../home/"; }, 500);
156+
setTimeout(() => { cooldown = false; }, 60000);
149157
} catch (err) {
150-
statusEl.textContent = `Fehler: ${err.message}`;
158+
statusEl.textContent = `Fehler beim Senden: ${err.message}`;
151159
statusEl.style.color = "#b00020";
152160
}
153161
});

0 commit comments

Comments
 (0)