diff --git a/frontend/components/Layout/Layout.js b/frontend/components/Layout/Layout.js index 15b034a84..131208e32 100644 --- a/frontend/components/Layout/Layout.js +++ b/frontend/components/Layout/Layout.js @@ -28,6 +28,7 @@ class Layout extends React.Component { user: React.PropTypes.object.isRequired, search: React.PropTypes.bool, offline: React.PropTypes.bool, + notifications: React.PropTypes.node, } static defaultProps = { @@ -67,6 +68,8 @@ class Layout extends React.Component { ) } + { this.props.notifications } +
Atlas diff --git a/frontend/scenes/Home/Home.js b/frontend/scenes/Home/Home.js index 308b955d1..2066f9d86 100644 --- a/frontend/scenes/Home/Home.js +++ b/frontend/scenes/Home/Home.js @@ -1,11 +1,12 @@ import React from 'react'; import { observer } from 'mobx-react'; -import { browserHistory } from 'react-router' +import { browserHistory } from 'react-router'; import { Flex } from 'reflexbox'; import Layout from 'components/Layout'; import CenteredContent from 'components/CenteredContent'; import SlackAuthLink from 'components/SlackAuthLink'; +import Alert from 'components/Alert'; import styles from './Home.scss'; @@ -13,6 +14,7 @@ import styles from './Home.scss'; export default class Home extends React.Component { static propTypes = { user: React.PropTypes.object.isRequired, + location: React.PropTypes.object.isRequired, } componentDidMount = () => { @@ -21,12 +23,27 @@ export default class Home extends React.Component { } } + get notifications() { + const notifications = []; + const { state } = this.props.location; + + if (state && state.nextPathname) { + sessionStorage.removeItem('redirectTo'); + sessionStorage.setItem('redirectTo', state.nextPathname); + notifications.push(Please login to continue); + } + + return notifications; + } + render() { const showLandingPageCopy = DEPLOYMENT === 'hosted'; return ( - + { showLandingPageCopy && (
diff --git a/frontend/scenes/SlackAuth/SlackAuth.js b/frontend/scenes/SlackAuth/SlackAuth.js index 01dfe7ee3..96ff73cdb 100644 --- a/frontend/scenes/SlackAuth/SlackAuth.js +++ b/frontend/scenes/SlackAuth/SlackAuth.js @@ -12,7 +12,11 @@ class SlackAuth extends React.Component { } componentDidMount = async () => { - const { error, code, state } = this.props.location.query; + const { + error, + code, + state, + } = this.props.location.query; if (error) { if (error === 'access_denied') { @@ -34,7 +38,10 @@ class SlackAuth extends React.Component { } } else { // Regular Slack authentication - this.props.user.authWithSlack(code, state); + const redirectTo = sessionStorage.getItem('redirectTo'); + sessionStorage.removeItem('redirectTo'); + + this.props.user.authWithSlack(code, state, redirectTo); } } diff --git a/frontend/stores/UserStore.js b/frontend/stores/UserStore.js index cb26ad540..222572d17 100644 --- a/frontend/stores/UserStore.js +++ b/frontend/stores/UserStore.js @@ -42,7 +42,7 @@ class UserStore { return this.oauthState; } - @action authWithSlack = async (code, state) => { + @action authWithSlack = async (code, state, redirectTo) => { if (state !== this.oauthState) { browserHistory.push('/auth-error'); return; @@ -50,7 +50,7 @@ class UserStore { let res; try { - res = await client.post('/auth.slack', { code: code }); + res = await client.post('/auth.slack', { code }); } catch (e) { browserHistory.push('/auth-error'); return; @@ -59,7 +59,7 @@ class UserStore { this.user = res.data.user; this.team = res.data.team; this.token = res.data.accessToken; - browserHistory.replace('/dashboard'); + browserHistory.replace(redirectTo || '/'); } constructor() { @@ -70,7 +70,7 @@ class UserStore { this.token = data.token; this.oauthState = data.oauthState; } -}; +} export default UserStore; export {