Skip to content

Commit ac259b0

Browse files
committed
small fix to actually show error messages on auth page
1 parent 4cd3b49 commit ac259b0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

auth.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -641,20 +641,16 @@ <h2 style="margin:0 0 4px; font-size:22px; font-weight:500;">Link This Account</
641641

642642
try {
643643
const account_data = await requestAccount(username, hash);
644-
if (account_data) {
644+
if (!Object.hasOwn(account_data, 'error')) {
645645
account = account_data;
646-
// Save successful login
647646
saveAccount(account_data);
648647
updateModalForLoggedInUser();
649648
} else {
650-
// Clear cookies on failed login
651649
document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
652650

653-
// Show error state
654-
submitButton.innerHTML = 'Invalid credentials';
651+
submitButton.innerHTML = account_data && account_data.error ? account_data.error : 'Invalid credentials';
655652
submitButton.style.background = '#ea4335';
656653

657-
// Reset after 2 seconds
658654
setTimeout(() => {
659655
submitButton.innerHTML = originalText;
660656
submitButton.style.background = '';
@@ -747,7 +743,7 @@ <h2 style="margin:0 0 4px; font-size:22px; font-weight:500;">Link This Account</
747743
setCookie("username", username, 7);
748744

749745
const account_data = await requestAccount(username, hash);
750-
if (account_data) {
746+
if (!Object.hasOwn(account_data, 'error')) {
751747
account = account_data;
752748
saveAccount(account_data);
753749
updateModalForLoggedInUser();
@@ -783,14 +779,17 @@ <h2 style="margin:0 0 4px; font-size:22px; font-weight:500;">Link This Account</
783779
if (json.error.includes("Terms-Of-Service") && json.token) {
784780
// Return a special object indicating TOS needs to be accepted
785781
return {
782+
error: json.error,
786783
key: json.token,
787784
username: username,
788785
"sys.tos_accepted": false,
789786
requiresTOSAcceptance: true
790787
};
791788
}
792789
console.error(json.error);
793-
return null;
790+
return {
791+
error: json.error
792+
};
794793
}
795794
return json;
796795
}

0 commit comments

Comments
 (0)