Cleaned up validators and browser-side ajax utils
This commit is contained in:
parent
8a4a21cff0
commit
cf55be21eb
8 changed files with 79 additions and 35 deletions
|
|
@ -63,11 +63,10 @@ class profileEditPrompt{
|
|||
updateObj[this.field] = this.prompt.value;
|
||||
|
||||
//contact server, and collect response
|
||||
var response = await utils.ajax.updateProfile(updateObj);
|
||||
var updated_content = (await response.json())[this.field];
|
||||
var updated_content = (await utils.ajax.updateProfile(updateObj))[this.field];
|
||||
|
||||
//Update label
|
||||
if(response.status == 200){
|
||||
if(updated_content != null){
|
||||
if(this.field == "img"){
|
||||
this.content.src = updated_content;
|
||||
}else{
|
||||
|
|
@ -76,7 +75,6 @@ class profileEditPrompt{
|
|||
}
|
||||
this.finish();
|
||||
}else if(event.key == "Escape" || event.key == "Enter"){
|
||||
console.log(response);
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
|
@ -144,7 +142,7 @@ class passwordResetPrompt{
|
|||
|
||||
const response = await utils.ajax.updateProfile(updateObj);
|
||||
|
||||
if(response.status == 200){
|
||||
if(response != null){
|
||||
//Return user homepage after good pass change, as we've probably been logged out by the server for security.
|
||||
window.location.pathname = '/';
|
||||
}
|
||||
|
|
@ -167,13 +165,7 @@ class deleteAccountPrompt{
|
|||
|
||||
async deletePrompt(event){
|
||||
const pass = window.prompt("Warning: You are about to nuke your account off of the face of the fucking planet, no taksie-backsies.\n \n (todo: replace with dialog that has obscured password input) \n Enter your password to confirm.");
|
||||
const response = await utils.ajax.deleteAccount(pass);
|
||||
|
||||
if(response.status == 200){
|
||||
window.location.pathname = '/';
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
await utils.ajax.deleteAccount(pass);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue