Ionic firebase Simple Login email and password Error


#1

TypeError: $firebaseAuth is not a function

ionic.bundle.js:26794 TypeError: Auth.$authWithPassword is not a function
at Scope.$scope.login (app.js:148)
at fn (eval at (ionic.bundle.js:27638), :4:206)
at ionic.bundle.js:65427
at Scope.$eval (ionic.bundle.js:30395)
at Scope.$apply (ionic.bundle.js:30495)
at HTMLAnchorElement. (ionic.bundle.js:65426)
at defaultHandlerWrapper (ionic.bundle.js:16787)
at HTMLAnchorElement.eventHandler (ionic.bundle.js:16775)
at triggerMouseEvent (ionic.bundle.js:2953)
at tapClick (ionic.bundle.js:2942)

I keep getting the above error. The controller is perfect. When used in a web app it works perfectly fine but in ionic it keeps giving error. Please help me.

My App.js ``

angular.module(‘dbcare’, [‘ionic’,‘firebase’])
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider

.state('login', {
url: '/login',
templateUrl: 'views/login.html',
controller: 'LoginCtrl'
})

.state('signup', {
url: '/signup',
templateUrl: 'views/signup.html',

})

$urlRouterProvider.otherwise('/login');
})

.factory(‘Auth’, function($firebaseAuth) {
var ref = new Firebase(“https//travelhighlights.firebaseio.com/”);
return $firebaseAuth(ref);
})indent preformatted text by 4 spaces

My Controller
.controller(‘LoginCtrl’,[’$scope’,’$ionicModal’,‘Auth’,’$location’, function ($scope,$ionicModal,$location,Auth) {

$scope.login = function() {

var username = $scope.email;
var password = $scope.password;

Auth.$authWithPassword({
        email: username,
        password: password
    })
    .then(function(authData) {

console.log(“Logged in as:”, authData.uid);
}).catch(function(error) {
console.error(“Authentication failed:”, error);
});

};

}])


#2

i have a sample application here, https://github.com/aaronksaunders/ionic-angularfire-sample/blob/master/www/js/controllers.js

make sure you have added both firebase and angularFire to your project

`

`

#3

Thank you aaronksaunders for replying. I have added the firebase.js and angularfire but before my app.js let me try adding them below the app.js and see. Also i will try to execute your code and see where i am going wrong. Thank you once again.


#4

Hi.
I have tried your example but I’m getting "controllers.js:20 Authentication failed: Error: The specified authentication provider is not enabled for this Firebase.(…)"
when I try to log in or create new account.

Do you have any idea what this could be?

Thanks!


#5

In app.js configure application with your firebase information

  //
  // SET THE CONSTANTS FOR THE REFS FOR FIREBASE/ANGULARFIRE
  .value("AUTHREF", new Firebase("https://[YOUR-STUFF].firebaseio.com/"))
  .value("TEXT_ITEMS_REF", new Firebase("https://[YOUR-STUFF].firebaseio.com/textItems"))

Sounds like a configuration issue and that you haven’t set up email authentication


#6

That solved it. Thanks.
I discovered Firebase to day any used console.firebase.google.com instead of .firebaseio.com
What is the difference?
It has to be connected, because my app-name/url is occupied in firebaseio since I have used it in google


#7

Hey aaronksaunders. Thanks man! Everything is AOK! Thanks a lot. There was a problem with dependency injection but your code straightened it all out.


#8

Hey Aaron,
do you habe any plans to update your sample project on github to firebase v3 now that there is an update to angularfire?


#9

There are already projects supporting ionic2 and the original ionic that supports firebase3.

They just fixed the issue last night for angularFire2 with Firebase3, so if you download those projects and install the latest versions you should be good to go.

I will update the projects this weekend.