Recently, I started learning Angular and decided to follow an online tutorial on creating a chat application. However, I encountered an issue when trying to register with an email and password - the error message "Firebase.createUser failed: First argument must contain the key 'password'" keeps popping up. Even though the app is not yet complete and I just finished the authentication part, I'm unsure of what steps to take next. Some advice from Google pointed me towards updating to the latest version of angularfire (1.1.3), which I did. Still stuck on how to proceed.
Here are some snippets from my code:
.state('register', {
url: '/register',
templateUrl: 'auth/register.html',
controller:'AuthCtrl as authCtrl',
resolve:{
requireNoAuth: function($state,Auth){
return Auth.$requireAuth()
.then(function(auth){
$state.go('home');
},
function(error){
return;
});
}
}
})
In authController.js:
angular.module('chatApp')
.controller('AuthCtrl', function (Auth, $state) {
//Following the 'Controller as' syntax instead of using $scope.
var authCtrl = this;
//User object for the controller
authCtrl.user = {
email:'',
pass:''
};
//Using Firebase functions for login with promises for success or failure
authCtrl.login = function () {
Auth.authWithPassword(authCtrl.user)
.then(function (auth) {
$state.go('home');
},
function (error) {
authCtrl.error = error;
});
};
//Function for registering user
authCtrl.register = function () {
Auth.$createUser(authCtrl.user)
.then(function (user) {
authCtrl.login();
},
function (error) {
authCtrl.error = error;
})
}
});
In authFactory.js:
angular.module('chatApp')
.factory('Auth',function($firebaseAuth,FirebaseUrl){
var declare= new Firebase(FirebaseUrl);
var auth=$firebaseAuth(declare);
return auth
});