Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Support APP_AUTH_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXyfir committed Mar 20, 2019
1 parent 99d4ff1 commit 8a7e40f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
9 changes: 8 additions & 1 deletion web/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ class _App extends React.Component<WithStyles<typeof styles>, AppState> {
<main className={classes.main}>
{account ? <Authenticated account={account} /> : <Unauthenticated />}
<div className={classes.div}>
<Button href={process.enve.APP_HOME_URL} color="secondary">
<Button
href={
account
? process.enve.APP_AUTH_URL.replace('%JWT%', '0')
: process.enve.APP_HOME_URL
}
color="secondary"
>
Back to {process.enve.NAME}
</Button>
</div>
Expand Down
16 changes: 9 additions & 7 deletions web/components/Unauthenticated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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() {
Expand All @@ -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 })
Expand Down

0 comments on commit 8a7e40f

Please sign in to comment.