mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
Fix avatar upload.
This commit is contained in:
@ -53,7 +53,7 @@ export const CropperDiv = (props) => {
|
||||
Setting.showMessage("error", "You must select a picture first!");
|
||||
return false;
|
||||
}
|
||||
Setting.showMessage("success", "uploading...");
|
||||
// Setting.showMessage("success", "uploading...");
|
||||
targetFunction(canvas.toDataURL());
|
||||
return true;
|
||||
}
|
||||
|
@ -77,19 +77,19 @@ export function getAffiliationOptions(url, code) {
|
||||
}
|
||||
|
||||
export function uploadAvatar(avatar) {
|
||||
let account;
|
||||
AuthBackend.getAccount("").then((res) => {
|
||||
account = res.data;
|
||||
let formData = new FormData();
|
||||
formData.append("avatarfile", avatar);
|
||||
formData.append("password", account.password);
|
||||
fetch(`${Setting.ServerUrl}/api/upload-avatar`, {
|
||||
body: formData,
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
}).then((res) => {
|
||||
let formData = new FormData();
|
||||
formData.append("avatarfile", avatar);
|
||||
fetch(`${Setting.ServerUrl}/api/upload-avatar`, {
|
||||
body: formData,
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
}).then(res => res.json())
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
window.location.href = "/account";
|
||||
});
|
||||
} else {
|
||||
Setting.showMessage("error", res.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user