accounts-frontend/src/pages/auth/SuccessOauthPage.tsx

78 lines
1.9 KiB
TypeScript
Raw Normal View History

2019-12-07 16:58:52 +05:30
import React from 'react';
import { Link } from 'react-router-dom';
import { FormattedMessage as Message } from 'react-intl';
import Helmet from 'react-helmet';
import loader from 'services/loader';
import rootMessages from 'pages/root/RootPage.intl.json';
2019-12-07 16:58:52 +05:30
import { Query } from 'services/request';
import styles from './success-oauth.scss';
import messages from './SuccessOauthPage.intl.json';
2019-12-07 16:58:52 +05:30
export default class SuccessOauthPage extends React.Component<{
location: {
2019-12-07 16:58:52 +05:30
query: Query<'appName'>;
};
2017-08-23 02:01:41 +05:30
}> {
componentDidMount() {
this.onPageUpdate();
setTimeout(() => {
try {
// try to close window if possible
2019-12-07 16:58:52 +05:30
// @ts-ignore
window.open('', '_self').close();
} catch (err) {
// don't care
}
}, 8000);
}
componentDidUpdate() {
this.onPageUpdate();
}
onPageUpdate() {
loader.hide();
}
render() {
const appName = this.props.location.query.get('appName');
return (
<div className={styles.page}>
<Message {...messages.title}>
{pageTitle => <Helmet title={pageTitle} />}
</Message>
<div className={styles.wrapper}>
<Link to="/" className={styles.logo}>
<Message {...rootMessages.siteName} />
</Link>
<div className={styles.title}>
<Message {...messages.applicationAuth} />
</div>
<div className={styles.checkmark} />
<div className={styles.description}>
{appName ? (
<Message
{...messages.authorizationForAppSuccessful}
values={{
appName: <b>{appName}</b>,
}}
/>
) : (
<Message {...messages.authorizationSuccessful} />
)}
&nbsp;
<Message {...messages.youCanCloseThisPage} />
</div>
</div>
</div>
);
}
}