Spaces:
Running
Running
Upload 10 files
Browse files- src/views/InstructorView.js +13 -2
src/views/InstructorView.js
CHANGED
|
@@ -362,8 +362,10 @@ export function setupInstructorEvents() {
|
|
| 362 |
// Google Auth Logic
|
| 363 |
authBtn.addEventListener('click', async () => {
|
| 364 |
try {
|
| 365 |
-
|
|
|
|
| 366 |
authBtn.classList.add('opacity-50');
|
|
|
|
| 367 |
|
| 368 |
const user = await signInWithGoogle();
|
| 369 |
const instructorData = await checkInstructorPermission(user);
|
|
@@ -380,7 +382,16 @@ export function setupInstructorEvents() {
|
|
| 380 |
}
|
| 381 |
} catch (error) {
|
| 382 |
console.error(error);
|
| 383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
authErrorMsg.classList.remove('hidden');
|
| 385 |
} finally {
|
| 386 |
authBtn.disabled = false;
|
|
|
|
| 362 |
// Google Auth Logic
|
| 363 |
authBtn.addEventListener('click', async () => {
|
| 364 |
try {
|
| 365 |
+
// Do NOT disable button immediately to prevent browser popup blocker
|
| 366 |
+
// authBtn.disabled = true;
|
| 367 |
authBtn.classList.add('opacity-50');
|
| 368 |
+
authErrorMsg.classList.add('hidden');
|
| 369 |
|
| 370 |
const user = await signInWithGoogle();
|
| 371 |
const instructorData = await checkInstructorPermission(user);
|
|
|
|
| 382 |
}
|
| 383 |
} catch (error) {
|
| 384 |
console.error(error);
|
| 385 |
+
let msg = error.message;
|
| 386 |
+
if (error.code === 'auth/popup-blocked') {
|
| 387 |
+
msg = "瀏覽器攔截了登入視窗。請允許此網站的彈出視窗,或不要在點擊後移動滑鼠。";
|
| 388 |
+
alert(msg);
|
| 389 |
+
}
|
| 390 |
+
if (error.code === 'auth/operation-not-allowed' || error.message.includes('invalid')) {
|
| 391 |
+
msg = "Google 登入功能未啟用。請前往 Firebase Console > Authentication開啟 Google Sign-In。";
|
| 392 |
+
alert(msg);
|
| 393 |
+
}
|
| 394 |
+
authErrorMsg.textContent = "登入失敗: " + msg;
|
| 395 |
authErrorMsg.classList.remove('hidden');
|
| 396 |
} finally {
|
| 397 |
authBtn.disabled = false;
|