Initial code for Slack based search
This commit is contained in:
@ -1,16 +1,31 @@
|
||||
import React from 'react';
|
||||
import { observer } from 'mobx-react';
|
||||
import { browserHistory } from 'react-router';
|
||||
import { client } from 'utils/ApiClient';
|
||||
|
||||
@observer(['user'])
|
||||
class SlackAuth extends React.Component {
|
||||
static propTypes = {
|
||||
user: React.PropTypes.object.isRequired,
|
||||
location: React.PropTypes.object.isRequired,
|
||||
route: React.PropTypes.object.isRequired,
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
componentDidMount = async () => {
|
||||
const { code, state } = this.props.location.query;
|
||||
this.props.user.authWithSlack(code, state);
|
||||
|
||||
if (this.props.route.apiPath) {
|
||||
try {
|
||||
await client.post(this.props.route.apiPath, { code });
|
||||
browserHistory.replace('/dashboard');
|
||||
} catch (e) {
|
||||
browserHistory.push('/auth-error');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Regular Slack authentication
|
||||
this.props.user.authWithSlack(code, state);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
Reference in New Issue
Block a user