mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-05 05:17:51 +08:00
properly handling update email request
This commit is contained in:
parent
6868ba4db6
commit
648bc4a36f
1 changed files with 16 additions and 13 deletions
|
@ -202,23 +202,26 @@ list.updateEmail = new SimplePopup(
|
|||
await user.reauthenticateWithCredential(credential);
|
||||
}
|
||||
Loader.show();
|
||||
axiosInstance
|
||||
.post("/user/updateEmail", {
|
||||
let response;
|
||||
try {
|
||||
axiosInstance.post("/user/updateEmail", {
|
||||
uid: user.uid,
|
||||
previousEmail: user.email,
|
||||
newEmail: email,
|
||||
})
|
||||
.then((data) => {
|
||||
Loader.hide();
|
||||
if (data.status === 200) {
|
||||
Notifications.add("Email updated", 0);
|
||||
setTimeout(() => {
|
||||
AccountController.signOut();
|
||||
}, 1000);
|
||||
} else {
|
||||
Notifications.add(data.message);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
Loader.hide();
|
||||
let msg = e?.response?.data?.message ?? e.message;
|
||||
Notifications.add("Failed to update email: " + msg, -1);
|
||||
return;
|
||||
}
|
||||
Loader.hide();
|
||||
if (response.status !== 200) {
|
||||
Notifications.add(response.data.message);
|
||||
return;
|
||||
} else {
|
||||
Notifications.add("Email updated", 1);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.code == "auth/wrong-password") {
|
||||
Notifications.add("Incorrect password", -1);
|
||||
|
|
Loading…
Reference in a new issue