diff --git a/src/components/user/User.js b/src/components/user/User.js index 6c0ae39..a4a6954 100644 --- a/src/components/user/User.js +++ b/src/components/user/User.js @@ -1,4 +1,4 @@ -import { PropTypes } from 'react'; +import PropTypes from 'prop-types'; /** * @typedef {object} User diff --git a/src/components/user/reducer.js b/src/components/user/reducer.js index c8b92f3..e17d533 100644 --- a/src/components/user/reducer.js +++ b/src/components/user/reducer.js @@ -1,18 +1,21 @@ // @flow import { UPDATE, SET, CHANGE_LANG } from './actions'; -export type User = { +export type User = {| id: ?number, uuid: ?string, token: string, username: string, email: string, avatar: string, - isGuest: boolean, - isActive: boolean, + lang: string, + isGuest: bool, + isActive: bool, passwordChangedAt: ?number, hasMojangUsernameCollision: bool, -}; + maskedEmail?: string, + shouldAcceptRules?: bool, +|}; const defaults: User = { @@ -32,8 +35,7 @@ const defaults: User = { hasMojangUsernameCollision: false, // frontend specific attributes - isGuest: true, - goal: null // the goal with wich user entered site + isGuest: true }; export default function user( diff --git a/src/index.js b/src/index.js index fd592c6..ed75d93 100644 --- a/src/index.js +++ b/src/index.js @@ -15,8 +15,9 @@ import loader from 'services/loader'; import logger from 'services/logger'; import font from 'services/font'; import history, { browserHistory } from 'services/history'; -import RootPage from 'pages/root/RootPage'; import AuthFlowRoute from 'containers/AuthFlowRoute'; +import RootPage from 'pages/root/RootPage'; +import SuccessOauthPage from 'pages/auth/SuccessOauthPage'; history.init(); @@ -39,7 +40,8 @@ Promise.all([ - null} /> + + null} /> diff --git a/src/pages/static/SuccessOauthPage.intl.json b/src/pages/auth/SuccessOauthPage.intl.json similarity index 100% rename from src/pages/static/SuccessOauthPage.intl.json rename to src/pages/auth/SuccessOauthPage.intl.json diff --git a/src/pages/static/SuccessOauthPage.js b/src/pages/auth/SuccessOauthPage.js similarity index 72% rename from src/pages/static/SuccessOauthPage.js rename to src/pages/auth/SuccessOauthPage.js index 133b036..089e614 100644 --- a/src/pages/static/SuccessOauthPage.js +++ b/src/pages/auth/SuccessOauthPage.js @@ -1,27 +1,48 @@ // @flow import React, { Component } from 'react'; -import { FooterMenu } from 'components/footerMenu'; - import { Link } from 'react-router-dom'; import { FormattedMessage as Message } from 'react-intl'; import Helmet from 'react-helmet'; -import styles from './success-oauth.scss'; +import loader from 'services/loader'; import rootMessages from 'pages/root/RootPage.intl.json'; + +import styles from './success-oauth.scss'; import messages from './SuccessOauthPage.intl.json'; -import profileStyles from 'pages/profile/profile.scss'; +import type { Query } from 'services/request'; export default class SuccessOauthPage extends Component { props: { - appName: ?string + location: { + query: Query<'appName'> + } }; + componentDidMount() { + this.onPageUpdate(); + + setTimeout(() => { + try { + // try to close window if possible + window.open('', '_self').close(); + } catch (err) { + // don't care + } + }, 8000); + } + + componentDidUpdate() { + this.onPageUpdate(); + } + + onPageUpdate() { + loader.hide(); + } + render() { - // TODO: detect GET param `appName` - // TODO: попытаться заркыть окно с помощью https://stackoverflow.com/a/31163281/5184751 - const {appName} = this.props; + const appName = this.props.location.query.get('appName'); return (
@@ -54,10 +75,6 @@ export default class SuccessOauthPage extends Component {
- -
- -
); } diff --git a/src/pages/static/success-oauth.scss b/src/pages/auth/success-oauth.scss similarity index 100% rename from src/pages/static/success-oauth.scss rename to src/pages/auth/success-oauth.scss diff --git a/src/pages/root/RootPage.js b/src/pages/root/RootPage.js index e377b89..4fe63d9 100644 --- a/src/pages/root/RootPage.js +++ b/src/pages/root/RootPage.js @@ -10,7 +10,6 @@ import AuthPage from 'pages/auth/AuthPage'; import ProfilePage from 'pages/profile/ProfilePage'; import RulesPage from 'pages/rules/RulesPage'; import PageNotFound from 'pages/404/PageNotFound'; -import SuccessOauthPage from 'pages/static/SuccessOauthPage'; import { restoreScroll } from 'functions'; import PrivateRoute from 'containers/PrivateRoute'; @@ -88,8 +87,6 @@ class RootPage extends Component { )}
- { /* TODO: это должен быть /oauth2/code/success */ } - diff --git a/src/services/request/index.js b/src/services/request/index.js index 7d9c662..72ac36a 100644 --- a/src/services/request/index.js +++ b/src/services/request/index.js @@ -1,6 +1,15 @@ import request from './request'; import InternalServerError from './InternalServerError'; +/** + * Usage: Query<'requeired'|'keys'|'names'> + * TODO: find a way to make it more friendly with URLSearchParams type + */ +export type Query = { + get: (key: T) => ?string, + set: (key: T, value: any) => void, +}; + export default request; export { InternalServerError };