Implemented /auth/error path
This commit is contained in:
parent
e4e5f900ee
commit
4ba98c9dcf
@ -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"
|
||||
/>
|
||||
<Route path="/auth/error" component={ ErrorAuth } />
|
||||
|
||||
<Route path="/404" component={ Error404 } />
|
||||
<Redirect from="*" to="/404" />
|
||||
|
23
frontend/scenes/ErrorAuth/ErrorAuth.js
Normal file
23
frontend/scenes/ErrorAuth/ErrorAuth.js
Normal file
@ -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 (
|
||||
<Layout
|
||||
titleText="Not Found"
|
||||
>
|
||||
<CenteredContent>
|
||||
<h1>Authentication failed</h1>
|
||||
|
||||
<p>We were unable to log you in. <Link to="/">Please try again.</Link></p>
|
||||
</CenteredContent>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ErrorAuth;
|
2
frontend/scenes/ErrorAuth/index.js
Normal file
2
frontend/scenes/ErrorAuth/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
import ErrorAuth from './ErrorAuth';
|
||||
export default ErrorAuth;
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user