mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-10 17:12:48 +00:00
wip - oauth
This commit is contained in:
@@ -9,6 +9,8 @@ import { NotFound } from './pages/NotFound/NotFound';
|
||||
import { Downloader } from './pages/Downloader/Downloader';
|
||||
import { Pubg } from './pages/Pubg/Pubg';
|
||||
import { Clips } from './pages/Clips';
|
||||
import { Oauth } from './pages/oauth/oauth';
|
||||
import 'babel-polyfill';
|
||||
|
||||
ReactDOM.render(
|
||||
<Router history={browserHistory}>
|
||||
@@ -18,6 +20,7 @@ ReactDOM.render(
|
||||
<Route path="/downloader" component={Downloader}/>
|
||||
<Route path="/pubg" component={Pubg}/>
|
||||
<Route path="/clips" component={Clips}/>
|
||||
<Route path="/oauth" component={Oauth}/>
|
||||
<Route path="*" component={NotFound}/>
|
||||
</Route>
|
||||
</Router>
|
||||
|
||||
@@ -3,6 +3,10 @@ import { Link } from 'react-router';
|
||||
|
||||
import './Navbar.scss';
|
||||
|
||||
// TODO: change url for build
|
||||
const redirectUri = 'https://localhost/oauth';
|
||||
const oauthUrl = `https://discordapp.com/api/oauth2/authorize?client_id=410818759746650140&redirect_uri=${redirectUri}&response_type=code&scope=email`;
|
||||
|
||||
interface Props {
|
||||
|
||||
}
|
||||
@@ -22,6 +26,7 @@ export class Navbar extends React.Component<Props, State> {
|
||||
<Link to="/downloader" className="Navbar__item" activeClassName="Navbar__item--active">Youtube Downloader</Link>
|
||||
<Link to="/pubg" className="Navbar__item" activeClassName="Navbar__item--active">Pubg</Link>
|
||||
<Link to="/clips" className="Navbar__item" activeClassName="Navbar__item--active">Clips</Link>
|
||||
<a href={oauthUrl} className="Navbar__item">Login</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
36
client/app/pages/oauth/oauth.tsx
Normal file
36
client/app/pages/oauth/oauth.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import { get } from 'lodash';
|
||||
import axios from 'axios';
|
||||
|
||||
interface Props {
|
||||
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
||||
}
|
||||
|
||||
export class Oauth extends React.Component<Props, State> {
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const code = get(this, 'props.location.query.code');
|
||||
|
||||
if (code) {
|
||||
// do stuff here
|
||||
this.fetchOauth(code as string);
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchOauth(code: string) {
|
||||
const res = await axios.post('/api/oauth', { code });
|
||||
console.log(res);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div></div>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user