1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-11 01:22:48 +00:00

wip - oauth

This commit is contained in:
2018-02-09 23:58:23 -06:00
parent 1fdeb3783a
commit 33c6e8e3fc
10 changed files with 195 additions and 27 deletions

View File

@@ -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>

View File

@@ -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>
);
}

View 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>
}
}

View File

@@ -9,7 +9,7 @@
},
"author": "Mitchell Gerber",
"license": "MIT",
"devDependencies": {
"dependencies": {
"@types/lodash": "^4.14.71",
"@types/react": "^16.0.0",
"@types/react-dom": "^15.5.1",
@@ -20,6 +20,7 @@
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",

View File

@@ -812,6 +812,14 @@ babel-plugin-transform-strict-mode@^6.22.0:
babel-runtime "^6.22.0"
babel-types "^6.22.0"
babel-polyfill@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
dependencies:
babel-runtime "^6.26.0"
core-js "^2.5.0"
regenerator-runtime "^0.10.5"
babel-preset-es2015@^6.18.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.22.0.tgz#af5a98ecb35eb8af764ad8a5a05eb36dc4386835"
@@ -907,6 +915,13 @@ babel-runtime@^6.18.0, babel-runtime@^6.22.0:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"
babel-runtime@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.11.0"
babel-template@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.22.0.tgz#403d110905a4626b317a2a1fcb8f3b73204b2edb"
@@ -1406,6 +1421,10 @@ core-js@^2.4.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e"
core-js@^2.5.0:
version "2.5.3"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e"
core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -4034,6 +4053,14 @@ regenerator-runtime@^0.10.0:
version "0.10.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.1.tgz#257f41961ce44558b18f7814af48c17559f9faeb"
regenerator-runtime@^0.10.5:
version "0.10.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
regenerator-runtime@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
regenerator-transform@0.9.8:
version "0.9.8"
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.9.8.tgz#0f88bb2bc03932ddb7b6b7312e68078f01026d6c"