added info change functionality

This commit is contained in:
Jacob Levine 2019-02-06 14:46:41 -06:00
parent e290f5ae11
commit c591c84c75
3 changed files with 143 additions and 1 deletions

View File

@ -27,7 +27,7 @@
New Email: <input type="text" name="NewEM" value="" id="newEM">
</div>
<div class="profileupdopt">
<input type='button' name="upd" value="Update Profile" id="upd">
<input type='button' name="upd" value="Update Profile" id="upd" onclick="upProfileInfo();">
</div>
</div>

View File

@ -52,6 +52,7 @@ var handleSignedInUser = function(user) {
document.getElementById('signout').style.display='inline-block';
document.getElementById('updpi').style.display='inline-block';
document.getElementById('deleteacc').style.display='inline-block';
document.getElementById('profileupd').style.display='none';
}
var handleSignedOutUser = function() {
document.getElementById("mainhead").innerHTML = "TitanScout- Sign In";
@ -59,6 +60,7 @@ var handleSignedOutUser = function() {
document.getElementById('signout').style.display='none';
document.getElementById('updpi').style.display='none';
document.getElementById('deleteacc').style.display='none';
document.getElementById('profileupd').style.display='none';
ui.start('#firebaseui-auth-container', uiConfig);
};
@ -98,3 +100,142 @@ function loadupdpi(){
handleSignedOutUser();
}
}
function upProfileInfo() {
if(firebase.auth().currentUser != null){
if(document.getElementById('newDN').value != ''){
user.updateProfile({
displayName: document.getElementById('newDN').value
}).then(function() {
if (document.getElementById('newPP').value != '') {
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) {
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.code)
}
});
}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.code)
}
});
}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.code)
}
});
}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.code)
}
});
}else{
if (document.getElementById('newPP').value != '') {
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) {
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.code)
}
});
}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.code)
}
});
}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.code)
}
});
}else{
handleSignedInUser();}
}
}else {
setTimeout(function() {
alert('Please sign in to change your account info.');
}, 1);
handleSignedOutUser();
}
}

View File

@ -15,4 +15,5 @@ body{
#profileupd{
display: none;
text-align: left;
}