Return code for /api/login

This commit is contained in:
Yang Luo
2021-03-20 13:05:34 +08:00
parent 7049e09570
commit 63a4066a8d
6 changed files with 32 additions and 75 deletions

View File

@ -51,13 +51,6 @@ export function logout() {
}).then(res => res.json());
}
export function getOAuthCode(clientId, responseType, redirectUri, scope, state) {
return fetch(`${authConfig.serverUrl}/api/oauth/code?clientId=${clientId}&responseType=${responseType}&redirectUri=${redirectUri}&scope=${scope}&state=${state}`, {
method: 'GET',
credentials: 'include',
}).then(res => res.json());
}
export function getApplication(owner, name) {
return fetch(`${authConfig.serverUrl}/api/get-application?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",

View File

@ -86,12 +86,17 @@ class Face extends React.Component {
}
onFinish(values) {
values.type = this.state.type;
AuthBackend.login(values)
.then((res) => {
if (res.status === 'ok') {
this.props.onLoggedIn();
Util.showMessage("success", `Logged in successfully`);
Util.goToLink("/");
if (this.state.type === "login") {
this.props.onLoggedIn();
Util.showMessage("success", `Logged in successfully`);
Util.goToLink("/");
} else if (this.state.type === "code") {
Util.showMessage("success", `Authorization code: ${res.data}`);
}
} else {
Util.showMessage("error", `Log in failed${res.msg}`);
}