Finished up with email password reset system.

This commit is contained in:
rainbow napkin 2024-12-28 15:36:42 -05:00
parent 3671b43789
commit 478edeeddf
13 changed files with 233 additions and 34 deletions

View file

@ -481,6 +481,27 @@ class canopyAjaxUtils{
}
}
async requestPasswordReset(user, verification){
const response = await fetch(`/api/account/passwordResetRequest`,{
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({user, verification})
});
//If we received a successful response
if(response.status == 200){
//Create pop-up
const popup = new canopyUXUtils.popup("A password reset link has been sent to the email associated with the account requested assuming it has one!");
//Go to home-page on pop-up closure
popup.popupDiv.addEventListener("close", ()=>{window.location = '/'});
//Otherwise
}else{
utils.ux.displayResponseError(await response.json());
}
}
async resetPassword(token, pass, confirmPass, verification){
const response = await fetch(`/api/account/passwordReset`,{
method: "POST",
@ -493,7 +514,7 @@ class canopyAjaxUtils{
//If we received a successful response
if(response.status == 200){
//Create pop-up
const popup = new canopyUXUtils.popup("Your password has been reset!");
const popup = new canopyUXUtils.popup("Your password has been reset, and all devices have been logged out of your account!");
//Go to home-page on pop-up closure
popup.popupDiv.addEventListener("close", ()=>{window.location = '/'});
//Otherwise