blob: 97b8c3693696defb1469793d1d01f6f8721c141d [file] [log] [blame]
import React from 'react'
import { Spin } from "antd";
import * as setting from '../Setting'
import * as Backend from '../Backend'
class Callback extends React.Component {
constructor(props) {
super(props);
this.state = {
classes: props,
addition: props.match.params.addition,
state: "",
code: ""
};
const params = new URLSearchParams(this.props.location.search);
this.state.code = params.get("code");
this.state.state = params.get("state");
setting.initFullClientUrl();
Backend.initServerUrl();
}
getAuthenticatedInfo() {
let redirectUrl;
redirectUrl = `${setting.ClientUrl}/callback/${this.state.addition}`;
Backend.githubLogin(this.state.code, this.state.state, redirectUrl, this.state.addition)
.then((res) => {
if (res.status === "fail") {
setting.showMessage("error", res?.msg);
}
this.props.history.push("/dashboard/home")
});
}
componentDidMount() {
this.getAuthenticatedInfo();
}
render() {
return (
<div className="App">
<Spin size="large" tip="Logging in..." style={{ paddingTop: "10%", paddingLeft: "50%" }} />
</div>
)
}
}
export default Callback;