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

use oauth for file uploads

This commit is contained in:
2018-02-19 16:06:33 -06:00
parent 79b4fecd3c
commit 02fe8e1748
16 changed files with 490 additions and 286 deletions

View File

@@ -1,36 +1,37 @@
import React from 'react';
import { get } from 'lodash';
import axios from 'axios';
import { storage } from '../../storage';
interface Props {
}
interface Props {}
interface State {
}
interface State {}
export class Oauth extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
constructor(props: Props) {
super(props);
}
componentDidMount() {
const code = get(this, 'props.location.query.code');
if (code) {
// do stuff here
this.fetchOauth(code as string);
}
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>
}
private async fetchOauth(code: string) {
try {
const res = await axios.post('/api/oauth', { code });
storage.setJWT(res.data);
window.location.href = '/';
} catch (e) {
console.error(e);
}
}
render() {
return <div />;
}
}