This commit is contained in:
Jacob Levine 2019-02-06 14:51:31 -06:00
parent c591c84c75
commit dc80127dee

View File

@ -10,8 +10,8 @@ var config = {
firebase.initializeApp(config);
// FirebaseUI config.
var uiConfig = {
callbacks:{
signInSuccessWithAuthResult:function(authResult, redirectUrl) {
callbacks: {
signInSuccessWithAuthResult: function(authResult, redirectUrl) {
if (authResult.user) {
handleSignedInUser(authResult.user);
}
@ -32,7 +32,9 @@ var uiConfig = {
// tosUrl and privacyPolicyUrl accept either url string or a callback
// function.
// Terms of service url/callback.
tosUrl: function(){alert("this is a test app. don't use it");},
tosUrl: function() {
alert("this is a test app. don't use it");
},
// Privacy policy url/callback.
privacyPolicyUrl: function() {
alert("we will steal all of the data");
@ -40,27 +42,27 @@ var uiConfig = {
};
var handleSignedInUser = function(user) {
document.getElementById("mainhead").innerHTML = "TitanScout- Create Form";
if (user.displayName != null){
if (user.displayName != null) {
document.getElementById('status').innerHTML = "You are signed in as: " + user.displayName;
}else if (user.email != null) {
} else if (user.email != null) {
document.getElementById('status').innerHTML = "You are signed in as: " + user.email;
}else if (user.phoneNumber != null) {
} else if (user.phoneNumber != null) {
document.getElementById('status').innerHTML = "You are signed in as: " + user.phoneNumber;
}else{
} else {
document.getElementById('status').innerHTML = "You are signed in.";
}
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';
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";
document.getElementById('status').innerHTML = "You are not signed in.";
document.getElementById('signout').style.display='none';
document.getElementById('updpi').style.display='none';
document.getElementById('deleteacc').style.display='none';
document.getElementById('profileupd').style.display='none';
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);
};
@ -85,24 +87,27 @@ var deleteAccount = function() {
}
}
};
function signout() {
var user = firebase.auth().currentUser;
firebase.auth().signOut()
handleSignedOutUser()
}
function loadupdpi(){
if(firebase.auth().currentUser != null){
document.getElementById('profileupd').style.display='block';
}else {
function loadupdpi() {
if (firebase.auth().currentUser != null) {
document.getElementById('profileupd').style.display = 'block';
} else {
setTimeout(function() {
alert('Please sign in to change your account info.');
}, 1);
handleSignedOutUser();
}
}
function upProfileInfo() {
if(firebase.auth().currentUser != null){
if(document.getElementById('newDN').value != ''){
if (firebase.auth().currentUser != null) {
if (document.getElementById('newDN').value != '') {
user.updateProfile({
displayName: document.getElementById('newDN').value
}).then(function() {
@ -110,7 +115,7 @@ function upProfileInfo() {
user.updateProfile({
photoURL: document.getElementById('newPP').value
}).then(function() {
if(document.getElementById('newEM').value != ''){
if (document.getElementById('newEM').value != '') {
user.updateEmail(document.getElementById('newEM').value).then(function() {
handleSignedInUser();
}).catch(function(error) {
@ -123,10 +128,10 @@ function upProfileInfo() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: "+error.code)
alert("An Error Occurred: " + error.code)
}
});
}else{
} else {
handleSignedInUser();
}
}).catch(function(error) {
@ -139,11 +144,11 @@ function upProfileInfo() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: "+error.code)
alert("An Error Occurred: " + error.code)
}
});
}else{
if(document.getElementById('newEM').value != ''){
} else {
if (document.getElementById('newEM').value != '') {
user.updateEmail(document.getElementById('newEM').value).then(function() {
handleSignedInUser();
}).catch(function(error) {
@ -156,11 +161,12 @@ function upProfileInfo() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: "+error.code)
alert("An Error Occurred: " + error.code)
}
});
}else{
handleSignedInUser();}
} else {
handleSignedInUser();
}
}
}).catch(function(error) {
if (error.code == 'auth/requires-recent-login') {
@ -172,15 +178,15 @@ function upProfileInfo() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: "+error.code)
alert("An Error Occurred: " + error.code)
}
});
}else{
} else {
if (document.getElementById('newPP').value != '') {
user.updateProfile({
photoURL: document.getElementById('newPP').value
}).then(function() {
if(document.getElementById('newEM').value != ''){
if (document.getElementById('newEM').value != '') {
user.updateEmail(document.getElementById('newEM').value).then(function() {
handleSignedInUser();
}).catch(function(error) {
@ -193,10 +199,10 @@ function upProfileInfo() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: "+error.code)
alert("An Error Occurred: " + error.code)
}
});
}else{
} else {
handleSignedInUser();
}
}).catch(function(error) {
@ -209,11 +215,11 @@ function upProfileInfo() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: "+error.code)
alert("An Error Occurred: " + error.code)
}
});
}else{
if(document.getElementById('newEM').value != ''){
} else {
if (document.getElementById('newEM').value != '') {
user.updateEmail(document.getElementById('newEM').value).then(function() {
handleSignedInUser();
}).catch(function(error) {
@ -226,11 +232,13 @@ function upProfileInfo() {
alert('Please sign in again to change your account info.');
}, 1);
} else {
alert("An Error Occurred: "+error.code)
alert("An Error Occurred: " + error.code)
}
});
}else{
handleSignedInUser();}
} else {
handleSignedInUser();
}
}
}
}else {
setTimeout(function() {