Help inscription verification

hi guys i want some help about my code it’s work however
it do the inscription but show me alert email exist if it is exit or not
and move on to the connection page …
$scope.inscription = function(nom,prenom,age,num,email,pass){
var t=0;
user.once(‘value’, function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var email1 = childSnapshot.val().Email;
if (email1 == email ){
t=1;
alert (“Email exist !!”);}
});
});

if (t==0){
user.push().set({
Nom : nom,
Prenom : prenom,
Age:age,
Num:num,
Email : email,
mdp: pass
})
$state.go(‘connexion’);
}
}