From 8a7e40f379c5778bb9b23e01ff17d6a75cfeee43 Mon Sep 17 00:00:00 2001 From: MrXyfir Date: Wed, 20 Mar 2019 10:49:26 -0700 Subject: [PATCH] Support APP_AUTH_URL --- web/components/App.tsx | 9 ++++++++- web/components/Unauthenticated.tsx | 16 +++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/web/components/App.tsx b/web/components/App.tsx index 578c55c..5f0f90e 100644 --- a/web/components/App.tsx +++ b/web/components/App.tsx @@ -62,7 +62,14 @@ class _App extends React.Component, AppState> {
{account ? : }
-
diff --git a/web/components/Unauthenticated.tsx b/web/components/Unauthenticated.tsx index f508851..6831103 100644 --- a/web/components/Unauthenticated.tsx +++ b/web/components/Unauthenticated.tsx @@ -75,7 +75,6 @@ export class _Unauthenticated extends React.Component< // Load reCAPTCHA lib after switching from login to register mode if (!prevState.create && this.state.create && process.enve.RECAPTCHA_KEY) { const element = document.createElement('script'); - element.type = 'text/javascript'; element.src = 'https://www.google.com/recaptcha/api.js'; document.head.appendChild(element); this.onChangeEmail(this.state.email); @@ -84,11 +83,8 @@ export class _Unauthenticated extends React.Component< onChangeCreate() { const { create } = this.state; - if (create) { - this.setState({ create: false, available: true }); - } else { - this.setState({ create: true, otp: '' }); - } + if (create) this.setState({ create: false, available: true }); + else this.setState({ create: true, otp: '' }); } onRegister() { @@ -107,7 +103,13 @@ export class _Unauthenticated extends React.Component< pass ? api .post('/login', { email, pass, otp: otp || undefined }) - .then(() => (location.href = process.enve.ACCOWNT_WEB_URL)) + .then( + res => + (location.href = process.enve.APP_AUTH_URL.replace( + '%JWT%', + res.data.jwt + )) + ) .catch(err => alert(`Error! ${err.response.data.error}`)) : api .post('/login/passwordless', { email })