Spaces:
Running
Running
Upload 10 files
Browse files- src/views/InstructorView.js +20 -5
src/views/InstructorView.js
CHANGED
|
@@ -393,14 +393,29 @@ export function setupInstructorEvents() {
|
|
| 393 |
btn.disabled = true;
|
| 394 |
|
| 395 |
try {
|
| 396 |
-
await loginWithEmail(email, password);
|
| 397 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
} catch (e) {
|
| 399 |
console.error("Login Error:", e);
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
|
|
|
| 403 |
}
|
|
|
|
| 404 |
btn.textContent = originalText;
|
| 405 |
btn.disabled = false;
|
| 406 |
}
|
|
|
|
| 393 |
btn.disabled = true;
|
| 394 |
|
| 395 |
try {
|
| 396 |
+
const user = await loginWithEmail(email, password);
|
| 397 |
+
// Manually trigger success flow to avoid listener delays/detachments
|
| 398 |
+
console.log("Login success, checking permissions manually...");
|
| 399 |
+
const instructorData = await checkInstructorPermission(user);
|
| 400 |
+
|
| 401 |
+
if (instructorData) {
|
| 402 |
+
const liveAuthModal = document.getElementById('auth-modal');
|
| 403 |
+
if (liveAuthModal) liveAuthModal.classList.add('hidden');
|
| 404 |
+
if (typeof checkPermissions === 'function') {
|
| 405 |
+
checkPermissions(instructorData);
|
| 406 |
+
}
|
| 407 |
+
} else {
|
| 408 |
+
throw new Error("無此帳號權限");
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
} catch (e) {
|
| 412 |
console.error("Login Error:", e);
|
| 413 |
+
const liveAuthErrorMsg = document.getElementById('auth-error');
|
| 414 |
+
if (liveAuthErrorMsg) {
|
| 415 |
+
liveAuthErrorMsg.textContent = "登入失敗: " + e.message;
|
| 416 |
+
liveAuthErrorMsg.classList.remove('hidden');
|
| 417 |
}
|
| 418 |
+
} finally {
|
| 419 |
btn.textContent = originalText;
|
| 420 |
btn.disabled = false;
|
| 421 |
}
|