mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
Change /api/auth/login to POST.
This commit is contained in:
@ -44,10 +44,11 @@ export function logout() {
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
export function authLogin(applicationName, providerName, code, state, redirectUri, method) {
|
||||
return fetch(`${authConfig.serverUrl}/api/auth/login?application=${applicationName}&provider=${providerName}&code=${code}&state=${state}&redirect_url=${redirectUri}&method=${method}`, {
|
||||
method: 'GET',
|
||||
credentials: 'include',
|
||||
export function authLogin(values) {
|
||||
return fetch(`${authConfig.serverUrl}/api/auth/login`, {
|
||||
method: 'POST',
|
||||
credentials: "include",
|
||||
body: JSON.stringify(values),
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,10 @@
|
||||
// limitations under the License.
|
||||
|
||||
import React from "react";
|
||||
import {message, Spin} from "antd";
|
||||
import {Spin} from "antd";
|
||||
import {withRouter} from "react-router-dom";
|
||||
import * as AuthBackend from "./AuthBackend";
|
||||
import * as Util from "./Util";
|
||||
|
||||
class AuthCallback extends React.Component {
|
||||
constructor(props) {
|
||||
@ -35,26 +36,22 @@ class AuthCallback extends React.Component {
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.authLogin();
|
||||
}
|
||||
|
||||
showMessage(type, text) {
|
||||
if (type === "success") {
|
||||
message.success(text);
|
||||
} else if (type === "error") {
|
||||
message.error(text);
|
||||
}
|
||||
}
|
||||
|
||||
authLogin() {
|
||||
let redirectUri;
|
||||
redirectUri = `${window.location.origin}/callback/${this.state.applicationName}/${this.state.providerName}/${this.state.method}`;
|
||||
AuthBackend.authLogin(this.state.applicationName, this.state.providerName, this.state.code, this.state.state, redirectUri, this.state.method)
|
||||
const body = {
|
||||
application: this.state.applicationName,
|
||||
provider: this.state.providerName,
|
||||
code: this.state.code,
|
||||
state: this.state.state,
|
||||
redirectUri: redirectUri,
|
||||
method: this.state.method,
|
||||
};
|
||||
AuthBackend.authLogin(body)
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
window.location.href = '/';
|
||||
} else {
|
||||
this.showMessage("error", res?.msg);
|
||||
Util.showMessage("error", res?.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user