From cc004de147fb582c0181a601a436eeabf302a99d Mon Sep 17 00:00:00 2001 From: Miodec Date: Fri, 13 May 2022 09:53:12 +0200 Subject: [PATCH] added function for users that got stuck with a google account that no longer exists --- .../src/ts/controllers/account-controller.ts | 18 ++++++++++++++++++ frontend/src/ts/index.ts | 3 +++ frontend/src/ts/types/types.d.ts | 1 + 3 files changed, 22 insertions(+) diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index d8366f0ce..6e902184d 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -401,6 +401,24 @@ export async function addGoogleAuth(): Promise { }); } +export function noGoogleNoMo(): void { + const user = Auth.currentUser; + if (user === null) return; + 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 + ); + }); +} + export async function removeGoogleAuth(): Promise { const user = Auth.currentUser; if (user === null) return; diff --git a/frontend/src/ts/index.ts b/frontend/src/ts/index.ts index a672c07b3..289bea9ad 100644 --- a/frontend/src/ts/index.ts +++ b/frontend/src/ts/index.ts @@ -28,6 +28,7 @@ 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"; type ExtendedGlobal = typeof globalThis & MonkeyTypes.Global; @@ -52,3 +53,5 @@ extendedGlobal.getTimerStats = TestTimer.getTimerStats; extendedGlobal.toggleUnsmoothedRaw = Result.toggleUnsmoothedRaw; extendedGlobal.enableSpacingDebug = TestInput.enableSpacingDebug; + +extendedGlobal.noGoogleNoMo = noGoogleNoMo; diff --git a/frontend/src/ts/types/types.d.ts b/frontend/src/ts/types/types.d.ts index 33cbc4c6f..1f1ad7243 100644 --- a/frontend/src/ts/types/types.d.ts +++ b/frontend/src/ts/types/types.d.ts @@ -550,6 +550,7 @@ declare namespace MonkeyTypes { getTimerStats(): TimerStats[]; toggleUnsmoothedRaw(): void; enableSpacingDebug(): void; + noGoogleNoMo(): void; } interface GithubRelease {