aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/GoogleAuthenticationManager.tsx
diff options
context:
space:
mode:
authorSkitty1238 <157652284+Skitty1238@users.noreply.github.com>2025-06-06 21:29:00 -0400
committerSkitty1238 <157652284+Skitty1238@users.noreply.github.com>2025-06-06 21:29:00 -0400
commitee7da91564ae293f394b487f96c53f0118af9d7b (patch)
tree953af327554b6d848447909cab0f55826425f04b /src/client/apis/GoogleAuthenticationManager.tsx
parent0c084cdc58c45c5315ff60f6a34f73fc722e25c9 (diff)
cleaned up popups so that not linking to Google doesnt bombard user with popups. Added debuggign instructions to alerts
Diffstat (limited to 'src/client/apis/GoogleAuthenticationManager.tsx')
-rw-r--r--src/client/apis/GoogleAuthenticationManager.tsx62
1 files changed, 19 insertions, 43 deletions
diff --git a/src/client/apis/GoogleAuthenticationManager.tsx b/src/client/apis/GoogleAuthenticationManager.tsx
index 23e658329..67a6e01e9 100644
--- a/src/client/apis/GoogleAuthenticationManager.tsx
+++ b/src/client/apis/GoogleAuthenticationManager.tsx
@@ -41,49 +41,6 @@ export class GoogleAuthenticationManager extends ObservableReactComponent<object
this.openState && this.resetState(0, 0);
}
- // public fetchOrGenerateAccessToken = async (displayIfFound = false) => {
- // const response = await Networking.FetchFromServer('/readGoogleAccessToken');
- // // if this is an authentication url, activate the UI to register the new access token
-
- // if (new RegExp(AuthenticationUrl).test(response)) {
- // this.isOpen = true;
- // this.authenticationLink = response;
-
- // // GETS STUCK AT THIS PROMISE!!
- // return new Promise<string>(resolve => {
- // this.disposer?.();
- // this.disposer = reaction(
- // () => this.authenticationCode,
- // async authenticationCode => {
- // if (authenticationCode && /\d{1}\/[\w-]{55}/.test(authenticationCode)) {
- // resolve(authenticationCode);
- // this.disposer?.();
- // // const response2 = await Networking.PostToServer('/writeGoogleAccessToken', { authenticationCode });
- // // runInAction(() => {
- // // this.success = true;
- // // this.credentials = response2 as { user_info: { name: string; picture: string }; access_token: string };
- // // });
- // // resolve((response2 as { access_token: string }).access_token);
- // this.resetState();
- // }
- // }
- // );
- // });
- // }
-
- // // otherwise, we already have a valid, stored access token and user info
- // const response2 = JSON.parse(response) as { user_info: { name: string; picture: string }; access_token: string };
- // if (displayIfFound) {
- // runInAction(() => {
- // this.success = true;
- // this.credentials = response2;
- // });
- // this.resetState(-1, -1);
- // this.isOpen = true;
- // }
- // return (response2 as { access_token: string }).access_token;
- // };
-
public fetchOrGenerateAccessToken = async (): Promise<string | undefined> => {
const response = await Networking.FetchFromServer('/readGoogleAccessToken');
@@ -111,6 +68,25 @@ export class GoogleAuthenticationManager extends ObservableReactComponent<object
}
};
+ public fetchAccessTokenSilently = async (): Promise<string | undefined> => {
+ const response = await Networking.FetchFromServer('/readGoogleAccessToken');
+
+ try {
+ const parsed = JSON.parse(response) as { access_token: string; user_info: { name: string; picture: string } };
+
+ runInAction(() => {
+ this.success = true;
+ this.credentials = parsed;
+ });
+
+ return parsed.access_token;
+ } catch {
+ // Do nothing — just return undefined silently
+ return undefined;
+ }
+ };
+
+
resetState = action((visibleForMS: number = 3000, fadesOutInMS: number = 500) => {
if (!visibleForMS && !fadesOutInMS) {
runInAction(() => {