diff options
Diffstat (limited to 'src/client/apis/HypothesisAuthenticationManager.tsx')
-rw-r--r-- | src/client/apis/HypothesisAuthenticationManager.tsx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/client/apis/HypothesisAuthenticationManager.tsx b/src/client/apis/HypothesisAuthenticationManager.tsx index cffb87227..b299f233e 100644 --- a/src/client/apis/HypothesisAuthenticationManager.tsx +++ b/src/client/apis/HypothesisAuthenticationManager.tsx @@ -6,6 +6,7 @@ import { Opt } from "../../fields/Doc"; import { Networking } from "../Network"; import "./HypothesisAuthenticationManager.scss"; import { Scripting } from "../util/Scripting"; +import { Hypothesis } from "./hypothesis/HypothesisApiUtils"; const prompt = "Paste authorization code here..."; @@ -44,12 +45,13 @@ export default class HypothesisAuthenticationManager extends React.Component<{}> this.disposer = reaction( () => this.authenticationCode, async authenticationCode => { - if (authenticationCode) { + const userProfile = authenticationCode && await Hypothesis.fetchUser(authenticationCode); + if (userProfile && userProfile.userid !== null) { this.disposer?.(); Networking.PostToServer("/writeHypothesisAccessToken", { authenticationCode }); runInAction(() => { this.success = true; - this.credentials = response; + this.credentials = Hypothesis.extractUsername(userProfile.userid); // extract username from profile }); this.resetState(); resolve(authenticationCode); |