mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
req.Header.Add("Authorization", "token " + token.AccessToken)
|
req.Header.Add("Authorization", "token "+token.AccessToken)
|
||||||
response, err := httpClient.Do(req)
|
response, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -115,7 +115,7 @@ func (c *ApiController) AuthGithub() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
req.Header.Add("Authorization", "token " + token.AccessToken)
|
req.Header.Add("Authorization", "token "+token.AccessToken)
|
||||||
response2, err := httpClient.Do(req)
|
response2, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -175,6 +175,5 @@ func (c *ApiController) AuthGithub() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
|
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import AccountPage from "./account/AccountPage";
|
|||||||
import LoginPage from "./account/LoginPage";
|
import LoginPage from "./account/LoginPage";
|
||||||
import HomePage from "./basic/HomePage";
|
import HomePage from "./basic/HomePage";
|
||||||
import CustomGithubCorner from "./CustomGithubCorner";
|
import CustomGithubCorner from "./CustomGithubCorner";
|
||||||
import CallbackBox from "./common/AuthBox";
|
import AuthCallback from "./common/AuthCallback";
|
||||||
|
|
||||||
const { Header, Footer } = Layout;
|
const { Header, Footer } = Layout;
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ class App extends Component {
|
|||||||
</Header>
|
</Header>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<LoginPage onLoggedIn={this.onLoggedIn.bind(this)} {...props} />)}/>
|
<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="/" 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="/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} />)}/>
|
<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());
|
}).then(res => res.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function githubLogin(providerName, code, state, redirectUrl, addition) {
|
export function authLogin(providerName, code, state, redirectUrl, addition) {
|
||||||
console.log(redirectUrl)
|
console.log(redirectUrl)
|
||||||
return fetch(`${Setting.ServerUrl}/api/auth/github?provider=${providerName}&code=${code}&state=${state}&redirect_url=${redirectUrl}&addition=${addition}`, {
|
return fetch(`${Setting.ServerUrl}/api/auth/github?provider=${providerName}&code=${code}&state=${state}&redirect_url=${redirectUrl}&addition=${addition}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
@ -17,40 +17,34 @@ import {withRouter} from "react-router-dom";
|
|||||||
import * as Setting from "../Setting";
|
import * as Setting from "../Setting";
|
||||||
import * as AccountBackend from "../backend/AccountBackend";
|
import * as AccountBackend from "../backend/AccountBackend";
|
||||||
|
|
||||||
class CallbackBox extends React.Component {
|
class AuthCallback extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
const params = new URLSearchParams(this.props.location.search);
|
||||||
this.state = {
|
this.state = {
|
||||||
classes: props,
|
classes: props,
|
||||||
providerType: props.match.params.providerType,
|
providerType: props.match.params.providerType,
|
||||||
providerName: props.match.params.providerName,
|
providerName: props.match.params.providerName,
|
||||||
addition: props.match.params.addition,
|
addition: props.match.params.addition,
|
||||||
state: "",
|
state: params.get("state"),
|
||||||
code: "",
|
code: params.get("code"),
|
||||||
isAuthenticated: false,
|
isAuthenticated: false,
|
||||||
isSignedUp: false,
|
isSignedUp: false,
|
||||||
email: ""
|
email: ""
|
||||||
};
|
};
|
||||||
const params = new URLSearchParams(this.props.location.search);
|
|
||||||
this.state.code = params.get("code");
|
|
||||||
this.state.state = params.get("state");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getAuthenticatedInfo() {
|
getAuthenticatedInfo() {
|
||||||
let redirectUrl;
|
let redirectUrl;
|
||||||
redirectUrl = `${Setting.ClientUrl}/callback/${this.state.providerType}/${this.state.providerName}/${this.state.addition}`;
|
redirectUrl = `${Setting.ClientUrl}/callback/${this.state.providerType}/${this.state.providerName}/${this.state.addition}`;
|
||||||
switch (this.state.providerType) {
|
AccountBackend.authLogin(this.state.providerName, this.state.code, this.state.state, redirectUrl, this.state.addition)
|
||||||
case "github":
|
.then((res) => {
|
||||||
AccountBackend.githubLogin(this.state.providerName, this.state.code, this.state.state, redirectUrl, this.state.addition)
|
if (res.status === "ok") {
|
||||||
.then((res) => {
|
window.location.href = '/';
|
||||||
if (res.status === "ok") {
|
}else {
|
||||||
window.location.href = '/';
|
Setting.showMessage("error", res?.msg);
|
||||||
}else {
|
}
|
||||||
Setting.showMessage("error", res?.msg);
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
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