mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-08 05:03:39 +08:00
added a more descriptive error to the sign up form
This commit is contained in:
parent
ee50cf96bf
commit
e4b468cc25
2 changed files with 12 additions and 4 deletions
|
|
@ -62,13 +62,17 @@ function isUsernameValid(name){
|
|||
}
|
||||
|
||||
exports.checkNameAvailability = functions.https.onCall((request,response) => {
|
||||
// 1 - available
|
||||
// -1 - unavailable (taken)
|
||||
// -2 - not valid name
|
||||
// -999 - unknown error
|
||||
try{
|
||||
if(!isUsernameValid(request.name)) return 0;
|
||||
if(!isUsernameValid(request.name)) return -2;
|
||||
return getAllNames().then(data => {
|
||||
let available = 1;
|
||||
data.forEach(name =>{
|
||||
try{
|
||||
if(name.toLowerCase() === request.name.toLowerCase()) available = 0;
|
||||
if(name.toLowerCase() === request.name.toLowerCase()) available = -1;
|
||||
}catch(e){
|
||||
//
|
||||
}
|
||||
|
|
@ -76,7 +80,7 @@ exports.checkNameAvailability = functions.https.onCall((request,response) => {
|
|||
return available;
|
||||
});
|
||||
}catch(e){
|
||||
return -1;
|
||||
return -999;
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -88,10 +88,14 @@ function signUp() {
|
|||
const namecheck = firebase.functions().httpsCallable('checkNameAvailability')
|
||||
|
||||
namecheck({name:nname}).then(d => {
|
||||
if(d.data === 0){
|
||||
if(d.data === -1){
|
||||
showNotification("Name unavailable", 3000);
|
||||
$(".pageLogin .preloader").addClass('hidden');
|
||||
return;
|
||||
}else if(d.data === -2){
|
||||
showNotification("Name cannot contain special characters or contain more than 12 characters. Can include _ . and -", 8000);
|
||||
$(".pageLogin .preloader").addClass('hidden');
|
||||
return;
|
||||
}else if(d.data === 1){
|
||||
if (password != passwordVerify) {
|
||||
showNotification("Passwords do not match", 3000);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue