I'm developing an app using the newest versions/SDK of
- Visual Studio
- Cordova
- Ionic
- AngularJS
- Firebase
- Genymotion
and I try to auth a user in my app via Firebase (email and password). I already searched the web for a solution but I simply don't get it working correctly.
Well, as soon as I click the register button (top right corner) I'll get this error message
This is the register.html (contains a form)
<ion-modal-view>
<div class="bar bar-header firstStart">
<div class="button button-clear button-positive" ng-click="closeModal()">
Schließen
</div>
<h1 class="title modalTitle">Registrieren </h1>
<div class="button button-clear button-positive"
ng-click="signupEmail()"> Speichern </div>
</div>
<ion-content class="has-header" padding="true">
<div class="list list-inset">
<label class="item item-input item-floating-label">
<i class="icon ion-ios-email placeholder-icon"></i>
<span class="input-label">E-Mail</span>
<input type="email" ng-model="data.email" placeholder="E-Mail" id="email">
</label>
<label class="item item-input item-floating-label">
<i class="icon ion-ios-locked placeholder-icon"></i>
<span class="input-label">Passwort</span>
<input type="password" ng-model="data.password"
placeholder="Passwort" id="password">
</label>
</div>
</ion-content>
app.js
.controller('modalController', ['$scope', '$ionicModal','$firebase',
function ($scope, $ionicModal,$firebase)
{
$ionicModal.fromTemplateUrl('templates/register.html', {
scope: $scope,
animation: 'slide-in-up',
backdropClickToClose: false,
hardwareBackButtonClose: false,
focusFirstInput: true
}).then(function (modal) {
$scope.modal = modal;
});
$scope.signupEmail = function () {
$scope.data = {};
var email = $scope.data.email;
alert(email);
var password = $scope.data.password;
alert(password);
/*if (email.length < 4) {
alert('Please enter an email address.');
return;
}
if (password.length < 4) {
alert('Please enter a password.');
return;
}*/
firebase.auth().createUserWithEmailAndPassword(email, password).catch(
function (error)
{
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode == 'auth/weak-password') {
alert('The password is too weak.');
} else {
alert(errorMessage);
}
if (errorCode == 'auth/argument-error') {
alert('Error with arg');
} else {
alert(errorMessage);
}
console.log(error);
// [END_EXCLUDE]
});
// [END createwithemail]
};
$scope.login = function () {
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
// User is signed in.
alert("User already signed in");
} else {
// No user is signed in.
firebase.auth().signInWithEmailAndPassword(email, password).catch(
function (error)
{
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
alert("error during login:" + errorMessage + "Code: " + errorCode);
})
}
});
};
$scope.openModal = function () {
$scope.modal.show();
};
$scope.closeModal = function () {
$scope.modal.hide();
};
// Cleanup the modal when we're done with it!
$scope.$on('$destroy', function () {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function () {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function () {
// Execute action
});
}]);
Please note that app.js contains two controller because one modal opens another modal if the user taps on the button at the top right corner
This function causes the error
This function is placed in app.js, just wanted to highlight it for you.
$scope.signupEmail = function () {
$scope.data = {};
var email = $scope.data.email;
alert(email);
var password = $scope.data.password;
alert(password);
firebase.auth().createUserWithEmailAndPassword(email, password).catch(
function (error)
{
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode == 'auth/weak-password') {
alert('The password is too weak.');
} else {
alert(errorMessage);
}
if (errorCode == 'auth/argument-error') {
alert('Error with arg');
} else {
alert(errorMessage);
}
console.log(error);
// [END_EXCLUDE]
});
// [END createwithemail]
};
Note: As you may see I'm printing out the password and email the user typed in to see its value but the only result I get is
What am I doing wrong? Your answers are very appreciated.
Thanks!