mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
Finish /login/oauth/authorize
This commit is contained in:
@ -327,14 +327,14 @@ class App extends Component {
|
||||
}
|
||||
|
||||
isDoorPages() {
|
||||
return window.location.pathname.startsWith('/login/oauth');
|
||||
return window.location.pathname.startsWith("/login/oauth/authorize");
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.isDoorPages()) {
|
||||
return (
|
||||
<Switch>
|
||||
<Route exact path="/login/oauth" render={(props) => this.renderLoginIfNotLoggedIn(<Face type={"code"} {...props} />)}/>
|
||||
<Route exact path="/login/oauth/authorize" render={(props) => this.renderLoginIfNotLoggedIn(<Face type={"code"} {...props} />)}/>
|
||||
</Switch>
|
||||
)
|
||||
}
|
||||
|
@ -247,9 +247,9 @@ class ApplicationEditPage extends React.Component {
|
||||
{i18next.t("application:Face Preview")}:
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<a style={{marginBottom: '10px'}} target="_blank" href={`/login/oauth?client_id=${this.state.application.clientId}&response_type=code&redirect_uri=${this.state.application.redirectUris[0]}&scope=read&state=casdoor`}>
|
||||
<a style={{marginBottom: '10px'}} target="_blank" href={`/login/oauth/authorize?client_id=${this.state.application.clientId}&response_type=code&redirect_uri=${this.state.application.redirectUris[0]}&scope=read&state=casdoor`}>
|
||||
{
|
||||
`${window.location.host}/login/oauth?client_id=${this.state.application.clientId}&response_type=code&redirect_uri=${this.state.application.redirectUris[0]}&scope=read&state=casdoor`
|
||||
`${window.location.host}/login/oauth/authorize?client_id=${this.state.application.clientId}&response_type=code&redirect_uri=${this.state.application.redirectUris[0]}&scope=read&state=casdoor`
|
||||
}
|
||||
</a>
|
||||
<br/>
|
||||
|
@ -21,28 +21,23 @@ import * as Util from "./Util";
|
||||
class AuthCallback extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const params = new URLSearchParams(this.props.location.search);
|
||||
this.state = {
|
||||
classes: props,
|
||||
applicationName: props.match.params.applicationName,
|
||||
providerName: props.match.params.providerName,
|
||||
method: props.match.params.method,
|
||||
state: params.get("state"),
|
||||
code: params.get("code"),
|
||||
isAuthenticated: false,
|
||||
isSignedUp: false,
|
||||
email: ""
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
const params = new URLSearchParams(this.props.location.search);
|
||||
let redirectUri;
|
||||
redirectUri = `${window.location.origin}/callback/${this.state.applicationName}/${this.state.providerName}/${this.state.method}`;
|
||||
const body = {
|
||||
application: this.state.applicationName,
|
||||
provider: this.state.providerName,
|
||||
code: this.state.code,
|
||||
state: this.state.state,
|
||||
code: params.get("code"),
|
||||
state: params.get("state"),
|
||||
redirectUri: redirectUri,
|
||||
method: this.state.method,
|
||||
};
|
||||
|
@ -91,7 +91,9 @@ class Face extends React.Component {
|
||||
Util.showMessage("success", `Logged in successfully`);
|
||||
Util.goToLink("/");
|
||||
} else if (this.state.type === "code") {
|
||||
Util.showMessage("success", `Authorization code: ${res.data}`);
|
||||
const code = res.data;
|
||||
Util.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`);
|
||||
// Util.showMessage("success", `Authorization code: ${res.data}`);
|
||||
}
|
||||
} else {
|
||||
Util.showMessage("error", `Log in failed:${res.msg}`);
|
||||
|
Reference in New Issue
Block a user