Reputation: 2625
I created a user login template. I want to sign up user with firebase.
I am getting the below error.
Error: Firebase.createUser failed: First argument must contain the key "email" with type "string" at Error (native)
My controller
.controller('LoginCtrl', ['$firebaseAuth','$scope','$timeout','$stateParams',function($firebaseAuth,$scope, $timeout, $stateParams) {
console.log("Login Control");
$scope.signupEmail = function() {
var ref = new Firebase("https://requestmaker.firebaseio.com");
ref.createUser({
email: $scope.email,
password: $scope.password
}, function(error, userData) {
if (error) {
console.log("Error creating user:", error);
} else {
console.log("Successfully created user account with uid:", userData.uid);
}
});
};
}]);
..In my index.html file, I have included
<!-- firebase.js -->
<script src="https://cdn.firebase.com/js/client/2.3.2/firebase.js"></script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/1.1.2/angularfire.min.js"></script>
..In my ionic view template
<button class="button button-full button-assertive" ng-click="signupEmail()">Login</button>
Some one please tell me where I am wrong.
.controller('SignInCtrl', function ($scope, $rootScope, $state, $ionicHistory, Auth, UserData, $firebase) {
$scope.hideBackButton = true;
/* FOR DEV PURPOSES */
$scope.user = {
email: "",
password: ""
};
$scope.signIn = function (user) {
$rootScope.show('Logging In...');
/* Check user fields*/
if(!user.email || !user.password){
$rootScope.hide();
$rootScope.notify('Error','Email or Password is incorrect!');
return;
}
/* All good, let's authentify */
Auth.$authWithPassword({
email : user.email,
password : user.password
}).then(function (authData) {
console.log(authData);
$rootScope.hide();
}).catch(function (error) {
$rootScope.hide();
$rootScope.notify('Error','Email or Password is incorrect!');
});
};
Thanks, Sabarisri
Upvotes: 0
Views: 469
Reputation: 2625
.controller('SignInCtrl', function ($scope, $rootScope, $state, $ionicHistory, Auth, UserData, $firebase) {
$scope.hideBackButton = true;
/* FOR DEV PURPOSES */
$scope.user = {
email: "",
password: ""
};
$scope.signIn = function (user) {
$rootScope.show('Logging In...');
/* Check user fields*/
if(!user.email || !user.password){
$rootScope.hide();
$rootScope.notify('Error','Email or Password is incorrect!');
return;
}
/* All good, let's authentify */
Auth.$authWithPassword({
email : user.email,
password : user.password
}).then(function (authData) {
console.log(authData);
$rootScope.hide();
}).catch(function (error) {
$rootScope.hide();
$rootScope.notify('Error','Email or Password is incorrect!');
});
};
Upvotes: 0