reworked fix profile info

This commit is contained in:
Jacob Levine 2019-02-06 15:22:09 -06:00
parent d9e7a1ed1e
commit e554a1df99

View File

@ -107,141 +107,97 @@ function loadupdpi() {
function upProfileInfo() {
if (firebase.auth().currentUser != null) {
var user = firebase.auth().currentUser;
if (document.getElementById('newDN').value != '') {
var user = firebase.auth.currentUser;
var newDN = document.getElementById('newDN').value;
var newEM = document.getElementById('newEM').value;
var newPP = document.getElementById('newPP').value;
var si = true
if (newDN != '' && newDN != user.displayName) {
if (newPP != '' && newPP != user.photoURL) {
try {
user.updateProfile({
displayName: document.getElementById('newDN').value
}).then(function() {
if (document.getElementById('newPP').value != '') {
displayName: newDN,
photoURL: newPP
});
} catch (error) {
if (error.code == 'auth/requires-recent-login') {
si = false;
// The user's credential is too old. She needs to sign in again.
signout()
// The timeout allows the message to be displayed after the UI has
// changed to the signed out state.
setTimeout(function() {
alert('Please sign in again to delete your account.');
}, 1);
} else {
alert("An error occurred: " + error)
}
}
} else {
try {
user.updateProfile({
photoURL: document.getElementById('newPP').value
}).then(function() {
if (document.getElementById('newEM').value != '') {
user.updateEmail(document.getElementById('newEM').value).then(function() {
handleSignedInUser();
}).catch(function(error) {
displayName: newDN
});
} catch (error) {
if (error.code == 'auth/requires-recent-login') {
si = false;
// The user's credential is too old. She needs to sign in again.
signout()
// The timeout allows the message to be displayed after the UI has
// changed to the signed out state.
setTimeout(function() {
alert('Please sign in again to change your account info.');
alert('Please sign in again to delete your account.');
}, 1);
} else {
alert("An Error Occurred: " +error)
}
});
} else {
handleSignedInUser();
}
}).catch(function(error) {
if (error.code == 'auth/requires-recent-login') {
// The user's credential is too old. She needs to sign in again.
signout()
// The timeout allows the message to be displayed after the UI has
// changed to the signed out state.
setTimeout(function() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: " +error)
}
});
} else {
if (document.getElementById('newEM').value != '') {
user.updateEmail(document.getElementById('newEM').value).then(function() {
handleSignedInUser();
}).catch(function(error) {
if (error.code == 'auth/requires-recent-login') {
// The user's credential is too old. She needs to sign in again.
signout()
// The timeout allows the message to be displayed after the UI has
// changed to the signed out state.
setTimeout(function() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: " +error)
}
});
} else {
handleSignedInUser();
alert("An error occurred: " + error)
}
}
}).catch(function(error) {
if (error.code == 'auth/requires-recent-login') {
// The user's credential is too old. She needs to sign in again.
signout()
// The timeout allows the message to be displayed after the UI has
// changed to the signed out state.
setTimeout(function() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: " +error)
}
});
} else {
if (document.getElementById('newPP').value != '') {
if (newPP != '' && newPP != user.photoURL) {
try {
user.updateProfile({
photoURL: document.getElementById('newPP').value
}).then(function() {
if (document.getElementById('newEM').value != '') {
user.updateEmail(document.getElementById('newEM').value).then(function() {
handleSignedInUser();
}).catch(function(error) {
photoURL: newPP
});
} catch (error) {
if (error.code == 'auth/requires-recent-login') {
si = false;
// The user's credential is too old. She needs to sign in again.
signout()
// The timeout allows the message to be displayed after the UI has
// changed to the signed out state.
setTimeout(function() {
alert('Please sign in again to delete your account.');
}, 1);
} else {
alert("An error occurred: " + error)
}
}
}
}
if (newEM != '' && newEM != user.email) {
try {
user.updateEmail(newEM)
} catch (error) {
si = false;
if (error.code == 'auth/requires-recent-login') {
// The user's credential is too old. She needs to sign in again.
signout()
// The timeout allows the message to be displayed after the UI has
// changed to the signed out state.
setTimeout(function() {
alert('Please sign in again to change your account info.');
alert('Please sign in again to delete your account.');
}, 1);
} else {
alert("An Error Occurred: " +error)
alert("An error occurred: " + error)
}
});
} else {
}
}
if (si) {
handleSignedInUser();
}
}).catch(function(error) {
if (error.code == 'auth/requires-recent-login') {
// The user's credential is too old. She needs to sign in again.
signout()
// The timeout allows the message to be displayed after the UI has
// changed to the signed out state.
setTimeout(function() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: " +error)
}
});
} else {
if (document.getElementById('newEM').value != '') {
user.updateEmail(document.getElementById('newEM').value).then(function() {
handleSignedInUser();
}).catch(function(error) {
if (error.code == 'auth/requires-recent-login') {
// The user's credential is too old. She needs to sign in again.
signout()
// The timeout allows the message to be displayed after the UI has
// changed to the signed out state.
setTimeout(function() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: " +error)
}
});
} else {
handleSignedInUser();
}
}
}
}else {
setTimeout(function() {
alert('Please sign in to change your account info.');
}, 1);