diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index 40c5562c3..a6fdcefe0 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -55,7 +55,7 @@ let canCall = true; export function sendVerificationEmail(): void { if (Auth === undefined) { - Notifications.add("Offline mode", -1, 3); + Notifications.add("Authentication uninitialized", -1, 3); return; } Loader.show(); @@ -353,7 +353,7 @@ if (Auth) { export function signIn(): void { if (Auth === undefined) { - Notifications.add("Offline mode", -1, 3); + Notifications.add("Authentication uninitialized", -1, 3); return; } @@ -397,7 +397,7 @@ export function signIn(): void { export async function forgotPassword(email: any): Promise { if (Auth === undefined) { - Notifications.add("Offline mode", -1, 3); + Notifications.add("Authentication uninitialized", -1, 3); return; } if (!canCall) { @@ -426,7 +426,7 @@ export async function forgotPassword(email: any): Promise { export async function signInWithGoogle(): Promise { if (Auth === undefined) { - Notifications.add("Offline mode", -1, 3); + Notifications.add("Authentication uninitialized", -1, 3); return; } @@ -471,7 +471,7 @@ export async function signInWithGoogle(): Promise { export async function addGoogleAuth(): Promise { if (Auth === undefined) { - Notifications.add("Offline mode", -1, 3); + Notifications.add("Authentication uninitialized", -1, 3); return; } Loader.show(); @@ -496,7 +496,7 @@ export async function addPasswordAuth( password: string ): Promise { if (Auth === undefined) { - Notifications.add("Offline mode", -1, 3); + Notifications.add("Authentication uninitialized", -1, 3); return; } Loader.show(); @@ -532,7 +532,7 @@ export async function addPasswordAuth( export function signOut(): void { if (Auth === undefined) { - Notifications.add("Offline mode", -1, 3); + Notifications.add("Authentication uninitialized", -1, 3); return; } if (!Auth.currentUser) return; @@ -558,7 +558,7 @@ export function signOut(): void { async function signUp(): Promise { if (Auth === undefined) { - Notifications.add("Offline mode", -1, 3); + Notifications.add("Authentication uninitialized", -1, 3); return; } RegisterCaptchaPopup.show(); @@ -733,7 +733,7 @@ $(".pageLogin .login .button.signInWithGoogle").on("click", () => { $("#top .signInOut").on("click", () => { if (Auth === undefined) { - Notifications.add("Offline mode", -1, 3); + Notifications.add("Authentication uninitialized", -1, 3); return; } if (Auth.currentUser) { diff --git a/frontend/src/ts/firebase.ts b/frontend/src/ts/firebase.ts index ce587897b..0802bb84e 100644 --- a/frontend/src/ts/firebase.ts +++ b/frontend/src/ts/firebase.ts @@ -3,6 +3,7 @@ import { FirebaseApp, initializeApp } from "firebase/app"; import { getAuth, Auth as AuthType } from "firebase/auth"; import { firebaseConfig } from "./constants/firebase-config"; // eslint-disable-line require-path-exists/exists import * as Notifications from "./elements/notifications"; +import { createErrorMessage } from "./utils/misc"; // Initialize Firebase export let app: FirebaseApp | undefined; @@ -15,15 +16,13 @@ try { app = undefined; Auth = undefined; console.error("Authentication failed to initialize", e); - const error = e as Error; - Notifications.addBanner( - "Authentication failed to initialize" + - (window.location.hostname === "localhost" ? ": " + error.message : ""), - 0, - undefined, - false - ); - // $("body").text( - // "Failed to initialize Firebase. Are you sure you have the correct config in the firebase-config.ts file?" - // ); + if (window.location.hostname === "localhost") { + Notifications.addBanner( + createErrorMessage(e, "Authentication uninitialized") + + " Check your firebase-config.ts", + 0, + undefined, + false + ); + } }