From 8f28a9c04bafd84f874c0eebf4dfc78585e3f1ea Mon Sep 17 00:00:00 2001 From: Miodec Date: Sun, 29 May 2022 14:34:28 +0200 Subject: [PATCH] removed function to remove google auth through the console --- .../src/ts/controllers/account-controller.ts | 57 ------------------- frontend/src/ts/index.ts | 3 - 2 files changed, 60 deletions(-) diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index d729ba50f..fc5916f8b 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -38,7 +38,6 @@ import { linkWithPopup, linkWithCredential, reauthenticateWithPopup, - unlink as unlinkAuth, getAdditionalUserInfo, sendPasswordResetEmail, User as UserType, @@ -409,58 +408,6 @@ export async function addGoogleAuth(): Promise { }); } -export function noGoogleNoMo(): void { - const user = Auth.currentUser; - if (user === null) return; - if ( - user.providerData.find((provider) => provider.providerId === "password") - ) { - unlinkAuth(user, "google.com") - .then(() => { - console.log("unlinked"); - Settings.updateAuthSections(); - }) - .catch((error) => { - console.log(error); - }); - } -} - -export async function removeGoogleAuth(): Promise { - const user = Auth.currentUser; - if (user === null) return; - if ( - user.providerData.find((provider) => provider.providerId === "password") - ) { - Loader.show(); - try { - await reauthenticateWithPopup(user, gmailProvider); - } catch (e) { - Loader.hide(); - const message = Misc.createErrorMessage(e, "Failed to reauthenticate"); - return Notifications.add(message, -1); - } - unlinkAuth(user, "google.com") - .then(() => { - Notifications.add("Google authentication removed", 1); - Loader.hide(); - Settings.updateAuthSections(); - }) - .catch((error) => { - Loader.hide(); - Notifications.add( - "Failed to remove Google authentication: " + error.message, - -1 - ); - }); - } else { - Notifications.add( - "Password authentication needs to be enabled to remove Google authentication", - -1 - ); - } -} - export async function addPasswordAuth( email: string, password: string @@ -710,10 +657,6 @@ $(".pageSettings #addGoogleAuth").on("click", async () => { addGoogleAuth(); }); -$(".pageSettings #removeGoogleAuth").on("click", () => { - removeGoogleAuth(); -}); - $(document).on("click", ".pageAccount .sendVerificationEmail", () => { sendVerificationEmail(); }); diff --git a/frontend/src/ts/index.ts b/frontend/src/ts/index.ts index a3d9f9978..65ddacd9e 100644 --- a/frontend/src/ts/index.ts +++ b/frontend/src/ts/index.ts @@ -28,7 +28,6 @@ import "./popups/mobile-test-config-popup"; import "./popups/edit-tags-popup"; import "./popups/google-sign-up-popup"; import * as Account from "./pages/account"; -import { noGoogleNoMo } from "./controllers/account-controller"; import "./elements/leaderboards"; type ExtendedGlobal = typeof globalThis & MonkeyTypes.Global; @@ -54,5 +53,3 @@ extendedGlobal.getTimerStats = TestTimer.getTimerStats; extendedGlobal.toggleUnsmoothedRaw = Result.toggleUnsmoothedRaw; extendedGlobal.enableSpacingDebug = TestInput.enableSpacingDebug; - -extendedGlobal.noGoogleNoMo = noGoogleNoMo;