From 4ba98c9dcfb96966c3df9eca17dc9bfa3efe6242 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 28 Aug 2016 10:59:34 -0700 Subject: [PATCH] Implemented /auth/error path --- frontend/index.js | 2 ++ frontend/scenes/ErrorAuth/ErrorAuth.js | 23 +++++++++++++++++++++++ frontend/scenes/ErrorAuth/index.js | 2 ++ frontend/scenes/SlackAuth/SlackAuth.js | 12 +++++++++++- 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 frontend/scenes/ErrorAuth/ErrorAuth.js create mode 100644 frontend/scenes/ErrorAuth/index.js diff --git a/frontend/index.js b/frontend/index.js index 0746ae45e..9dfd2d763 100644 --- a/frontend/index.js +++ b/frontend/index.js @@ -29,6 +29,7 @@ import SlackAuth from 'scenes/SlackAuth'; import Error404 from 'scenes/Error404'; window.stores = stores; +import ErrorAuth from 'scenes/ErrorAuth'; let DevTools; if (__DEV__) { @@ -78,6 +79,7 @@ render(( component={ SlackAuth } apiPath="/auth.slackCommands" /> + diff --git a/frontend/scenes/ErrorAuth/ErrorAuth.js b/frontend/scenes/ErrorAuth/ErrorAuth.js new file mode 100644 index 000000000..d0c25aefd --- /dev/null +++ b/frontend/scenes/ErrorAuth/ErrorAuth.js @@ -0,0 +1,23 @@ +import React from 'react'; +import { Link } from 'react-router'; + +import Layout from 'components/Layout'; +import CenteredContent from 'components/CenteredContent'; + +class ErrorAuth extends React.Component { + render() { + return ( + + +

Authentication failed

+ +

We were unable to log you in. Please try again.

+
+
+ ); + } +} + +export default ErrorAuth; diff --git a/frontend/scenes/ErrorAuth/index.js b/frontend/scenes/ErrorAuth/index.js new file mode 100644 index 000000000..fb4b27245 --- /dev/null +++ b/frontend/scenes/ErrorAuth/index.js @@ -0,0 +1,2 @@ +import ErrorAuth from './ErrorAuth'; +export default ErrorAuth; diff --git a/frontend/scenes/SlackAuth/SlackAuth.js b/frontend/scenes/SlackAuth/SlackAuth.js index 44a3eddbf..01dfe7ee3 100644 --- a/frontend/scenes/SlackAuth/SlackAuth.js +++ b/frontend/scenes/SlackAuth/SlackAuth.js @@ -12,7 +12,17 @@ class SlackAuth extends React.Component { } componentDidMount = async () => { - const { code, state } = this.props.location.query; + const { error, code, state } = this.props.location.query; + + if (error) { + if (error === 'access_denied') { + // User selected "Deny" access on Slack OAuth + browserHistory.push('/'); + } else { + browserHistory.push('/auth/error'); + } + return; + } if (this.props.route.apiPath) { try {