casdoor/web/src/auth/AuthBackend.js

65 lines
2.1 KiB
JavaScript
Raw Normal View History

feat: added avatar tailoring and uploading Signed-off-by: Kininaru <shiftregister233@outlook.com> fixed type errors Signed-off-by: Kininaru <shiftregister233@outlook.com> fixed the wrong folder Signed-off-by: Kininaru <shiftregister233@outlook.com> rewrite login check logic, added unix time to avatar url Signed-off-by: Kininaru <shiftregister233@outlook.com> fixed a bug about strconv Signed-off-by: Kininaru <shiftregister233@outlook.com> supported oss Signed-off-by: Kininaru <shiftregister233@outlook.com> disabled oss provide qiniu Signed-off-by: Kininaru <shiftregister233@outlook.com> Fixed avatar url error Signed-off-by: Kininaru <shiftregister233@outlook.com> Fixed avatar length bug Signed-off-by: Kininaru <shiftregister233@outlook.com> Fixed avatar length bug Signed-off-by: Kininaru <shiftregister233@outlook.com> fixed oss.conf Signed-off-by: Kininaru <shiftregister233@outlook.com> Put uploading avatar into UserEditPage Signed-off-by: Kininaru <shiftregister233@outlook.com> removed avatar dir Signed-off-by: Kininaru <shiftregister233@outlook.com> removed avatar in main.go Signed-off-by: Kininaru <shiftregister233@outlook.com> Made CropperDiv a reusable component, and updated README for OSS config Signed-off-by: Kininaru <shiftregister233@outlook.com> Convert ts to js Signed-off-by: Kininaru <shiftregister233@outlook.com> removed ts Signed-off-by: Kininaru <shiftregister233@outlook.com> fix: set avatar link to string 255 Signed-off-by: Kininaru <shiftregister233@outlook.com> fix: updated yarn lock Signed-off-by: Kininaru <shiftregister233@outlook.com> add: Casbin license Signed-off-by: Kininaru <shiftregister233@outlook.com>
2021-03-14 15:50:36 +08:00
// Copyright 2021 The casbin Authors. All Rights Reserved.
2021-02-13 12:15:19 +08:00
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2021-02-14 16:59:08 +08:00
import {authConfig} from "./Auth";
2021-02-14 15:51:56 +08:00
2021-05-16 18:18:55 +08:00
export function getAccount(query) {
return fetch(`${authConfig.serverUrl}/api/get-account${query}`, {
2021-02-13 12:15:19 +08:00
method: 'GET',
credentials: 'include'
}).then(res => res.json());
}
2021-04-27 22:47:44 +08:00
export function signup(values) {
return fetch(`${authConfig.serverUrl}/api/signup`, {
2021-02-13 12:15:19 +08:00
method: 'POST',
credentials: "include",
body: JSON.stringify(values),
}).then(res => res.json());
}
2021-03-20 16:51:10 +08:00
function oAuthParamsToQuery(oAuthParams) {
return `?clientId=${oAuthParams.clientId}&responseType=${oAuthParams.responseType}&redirectUri=${oAuthParams.redirectUri}&scope=${oAuthParams.scope}&state=${oAuthParams.state}`;
}
export function getApplicationLogin(oAuthParams) {
return fetch(`${authConfig.serverUrl}/api/get-app-login${oAuthParamsToQuery(oAuthParams)}`, {
2021-03-20 11:34:04 +08:00
method: 'GET',
credentials: 'include',
}).then(res => res.json());
}
2021-03-20 16:51:10 +08:00
export function login(values, oAuthParams) {
return fetch(`${authConfig.serverUrl}/api/login${oAuthParamsToQuery(oAuthParams)}`, {
2021-02-13 12:15:19 +08:00
method: 'POST',
credentials: "include",
body: JSON.stringify(values),
}).then(res => res.json());
}
export function logout() {
2021-02-14 16:59:08 +08:00
return fetch(`${authConfig.serverUrl}/api/logout`, {
2021-02-13 12:15:19 +08:00
method: 'POST',
credentials: "include",
}).then(res => res.json());
}
2021-02-14 00:22:24 +08:00
2021-04-18 23:14:46 +08:00
export function unlink(values) {
return fetch(`${authConfig.serverUrl}/api/unlink`, {
method: 'POST',
credentials: "include",
body: JSON.stringify(values),
2021-02-14 16:59:08 +08:00
}).then(res => res.json());
}