fixed a bug where users would be asked to change name right after registering

This commit is contained in:
Jack 2020-06-12 20:14:26 +01:00
parent d6f7097516
commit ea542ac2ac
2 changed files with 18 additions and 18 deletions

View file

@ -102,7 +102,7 @@ function signUp() {
// Account has been created here.
let usr = user.user;
usr.updateProfile({
displayName: name
displayName: nname
}).then(function() {
// Update successful.
showNotification("Account created", 2000);

View file

@ -125,23 +125,23 @@ function verifyUsername(){
Sorry for this inconvenience.
`);
let newName = prompt('Please provide a new username - you can use lowercase and uppercase characters, numbers and one of these special characters ( . _ - ). The new name cannot be longer than 12 characters.',firebase.auth().currentUser.displayName);
cn = firebase.functions().httpsCallable('changeName');
cn({uid:firebase.auth().currentUser.uid,name:newName}).then(d => {
if(d.data === 1){
//all good
alert('Thanks! All good.');
location.reload();
$('.nameChangeMessage').slideUp();
}else if(d.data === 0){
//invalid or unavailable
alert('Name invalid or taken. Try again.');
}else if(d.data === -1){
//error
alert('Unknown error. Contact Miodec on Discord.');
}
});
if(newName){
cn = firebase.functions().httpsCallable('changeName');
cn({uid:firebase.auth().currentUser.uid,name:newName}).then(d => {
if(d.data === 1){
//all good
alert('Thanks! All good.');
location.reload();
$('.nameChangeMessage').slideUp();
}else if(d.data === 0){
//invalid or unavailable
alert('Name invalid or taken. Try again.');
}else if(d.data === -1){
//error
alert('Unknown error. Contact Miodec on Discord.');
}
});
}
})
}