diff options
author | Sam Wilkins <35748010+samwilkins333@users.noreply.github.com> | 2019-12-02 12:21:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-02 12:21:09 -0500 |
commit | 0595f93dde717b7b6990e9a81c5b43a73a3808d5 (patch) | |
tree | af03ac257a5584f9913f120c44d4d39bb13916f2 /src/client/apis/GoogleAuthenticationManager.tsx | |
parent | 68f49ef5daf3bf5c47d1d21c8f1cd2097947d071 (diff) | |
parent | ae76fd39a6530ac055948bb7b98537d38b592ef6 (diff) |
Merge pull request #316 from browngraphicslab/server_refactor
Server refactor
Diffstat (limited to 'src/client/apis/GoogleAuthenticationManager.tsx')
-rw-r--r-- | src/client/apis/GoogleAuthenticationManager.tsx | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/client/apis/GoogleAuthenticationManager.tsx b/src/client/apis/GoogleAuthenticationManager.tsx index 01dac3996..ae77c4b7b 100644 --- a/src/client/apis/GoogleAuthenticationManager.tsx +++ b/src/client/apis/GoogleAuthenticationManager.tsx @@ -3,8 +3,7 @@ import { observer } from "mobx-react"; import * as React from "react"; import MainViewModal from "../views/MainViewModal"; import { Opt } from "../../new_fields/Doc"; -import { Identified } from "../Network"; -import { RouteStore } from "../../server/RouteStore"; +import { Networking } from "../Network"; import "./GoogleAuthenticationManager.scss"; const AuthenticationUrl = "https://accounts.google.com/o/oauth2/v2/auth"; @@ -31,7 +30,7 @@ export default class GoogleAuthenticationManager extends React.Component<{}> { } public fetchOrGenerateAccessToken = async () => { - let response = await Identified.FetchFromServer(RouteStore.readGoogleAccessToken); + let 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; @@ -39,24 +38,25 @@ export default class GoogleAuthenticationManager extends React.Component<{}> { return new Promise<string>(async resolve => { const disposer = reaction( () => this.authenticationCode, - authenticationCode => { - if (authenticationCode) { - Identified.PostToServer(RouteStore.writeGoogleAccessToken, { authenticationCode }).then( - ({ access_token, avatar, name }) => { - runInAction(() => { - this.avatar = avatar; - this.username = name; - }); - this.beginFadeout(); - disposer(); - resolve(access_token); - }, - action(() => { - this.hasBeenClicked = false; - this.success = false; - }) - ); + async authenticationCode => { + if (!authenticationCode) { + return; } + const { access_token, avatar, name } = await Networking.PostToServer( + "/writeGoogleAccessToken", + { authenticationCode } + ); + runInAction(() => { + this.avatar = avatar; + this.username = name; + }); + this.beginFadeout(); + disposer(); + resolve(access_token); + action(() => { + this.hasBeenClicked = false; + this.success = false; + }); } ); }); |