mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-22 18:25:47 +08:00
Fix code format.
This commit is contained in:
parent
c81118feff
commit
101d418257
@ -89,7 +89,7 @@ func (c *ApiController) AuthGithub() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
req.Header.Add("Authorization", "token " + token.AccessToken)
|
||||
req.Header.Add("Authorization", "token "+token.AccessToken)
|
||||
response, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -115,7 +115,7 @@ func (c *ApiController) AuthGithub() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
req.Header.Add("Authorization", "token " + token.AccessToken)
|
||||
req.Header.Add("Authorization", "token "+token.AccessToken)
|
||||
response2, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -175,6 +175,5 @@ func (c *ApiController) AuthGithub() {
|
||||
}
|
||||
|
||||
c.Data["json"] = resp
|
||||
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import AccountPage from "./account/AccountPage";
|
||||
import LoginPage from "./account/LoginPage";
|
||||
import HomePage from "./basic/HomePage";
|
||||
import CustomGithubCorner from "./CustomGithubCorner";
|
||||
import CallbackBox from "./common/AuthBox";
|
||||
import AuthCallback from "./common/AuthCallback";
|
||||
|
||||
const { Header, Footer } = Layout;
|
||||
|
||||
@ -274,7 +274,7 @@ class App extends Component {
|
||||
</Header>
|
||||
<Switch>
|
||||
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<LoginPage onLoggedIn={this.onLoggedIn.bind(this)} {...props} />)}/>
|
||||
<Route exact path="/callback/:providerType/:providerName/:addition" component={CallbackBox}/>
|
||||
<Route exact path="/callback/:providerType/:providerName/:addition" component={AuthCallback}/>
|
||||
<Route exact path="/" render={(props) => this.renderLoginIfNotLoggedIn(<HomePage account={this.state.account} onLoggedIn={this.onLoggedIn.bind(this)} {...props} />)}/>
|
||||
<Route exact path="/account" render={(props) => this.renderLoginIfNotLoggedIn(<AccountPage account={this.state.account} {...props} />)}/>
|
||||
<Route exact path="/organizations" render={(props) => this.renderLoginIfNotLoggedIn(<OrganizationListPage account={this.state.account} {...props} />)}/>
|
||||
|
@ -51,7 +51,7 @@ export function logout() {
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
export function githubLogin(providerName, code, state, redirectUrl, addition) {
|
||||
export function authLogin(providerName, code, state, redirectUrl, addition) {
|
||||
console.log(redirectUrl)
|
||||
return fetch(`${Setting.ServerUrl}/api/auth/github?provider=${providerName}&code=${code}&state=${state}&redirect_url=${redirectUrl}&addition=${addition}`, {
|
||||
method: 'GET',
|
||||
|
@ -17,40 +17,34 @@ import {withRouter} from "react-router-dom";
|
||||
import * as Setting from "../Setting";
|
||||
import * as AccountBackend from "../backend/AccountBackend";
|
||||
|
||||
class CallbackBox extends React.Component {
|
||||
class AuthCallback extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const params = new URLSearchParams(this.props.location.search);
|
||||
this.state = {
|
||||
classes: props,
|
||||
providerType: props.match.params.providerType,
|
||||
providerName: props.match.params.providerName,
|
||||
addition: props.match.params.addition,
|
||||
state: "",
|
||||
code: "",
|
||||
state: params.get("state"),
|
||||
code: params.get("code"),
|
||||
isAuthenticated: false,
|
||||
isSignedUp: false,
|
||||
email: ""
|
||||
};
|
||||
const params = new URLSearchParams(this.props.location.search);
|
||||
this.state.code = params.get("code");
|
||||
this.state.state = params.get("state");
|
||||
}
|
||||
|
||||
getAuthenticatedInfo() {
|
||||
let redirectUrl;
|
||||
redirectUrl = `${Setting.ClientUrl}/callback/${this.state.providerType}/${this.state.providerName}/${this.state.addition}`;
|
||||
switch (this.state.providerType) {
|
||||
case "github":
|
||||
AccountBackend.githubLogin(this.state.providerName, this.state.code, this.state.state, redirectUrl, this.state.addition)
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
window.location.href = '/';
|
||||
}else {
|
||||
Setting.showMessage("error", res?.msg);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
AccountBackend.authLogin(this.state.providerName, this.state.code, this.state.state, redirectUrl, this.state.addition)
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
window.location.href = '/';
|
||||
}else {
|
||||
Setting.showMessage("error", res?.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@ -68,4 +62,4 @@ class CallbackBox extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(CallbackBox);
|
||||
export default withRouter(AuthCallback);
|
Loading…
x
Reference in New Issue
Block a user