0

The problem here is that i need to somehow get the information of the user when he logs in. So what is happening is that when he register all goes fine he goes to another page and it says "Welcome" + username And it does it correctly! But when i do it with the login page the username becomes undefined. Im preety sure i like somehow need to store my data in a factory but stumbled on how to. Thats what i think but may not be true. Anways...

Here is the plunker: http://plnkr.co/edit/qB3Gkeq5ji1YQyy0kpGH

Thank you so much for your help!

1
  • While a plunkr is a great way to allow someone to quickly see your problem in context, it is by itself not enough for a question on StackOverflow. When you update your plunkr, the question becomes useless to people who stumble upon it in the future. Next time also include the minimal code that reproduces the problem in the question itself. See stackoverflow.com/help/mcve Commented Jan 10, 2016 at 18:23

1 Answer 1

1

Use FirebaseAuth

in your controller you're using firebase array not Auth. This is an extract of the correct way to auth with firebase.

// define our app and dependencies (remember to include firebase!)
var app = angular.module("sampleApp", ["firebase"]);
// inject $firebaseAuth into our controller
app.controller("SampleCtrl", ["$scope", "$firebaseAuth",
  function($scope, $firebaseAuth) {
    var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
    var auth = $firebaseAuth(ref);
  }
]);

Here is a link to the Docs with the exact tutorial. I would advise following it all the way through to learn firebase.

Sign up to request clarification or add additional context in comments.

4 Comments

It says in console ref2.authWithPassword is not a function When i try to do it your way. This is what i did: var ref = new Firebase("uniquecoders.firebaseio.com/"); var ref2 = $firebaseAuth(ref);
This is the docs im following.. firebase.com/docs/web/guide/login/password.html
That link describes email+password authentication for the regular Firebase JavaScript SDK. While AngularFire is built on top of (and interacts seamlessly with) that SDK, you'll have an easier time if you use AngularFire methods first and only fall back to regular SDK for stuff AngularFire doesn't cover. So study the AngularFire API documentation, specifically [$authWithPassword()])(firebase.com/docs/web/libraries/angular/…).
take some time to go through the entire doc for firebase and the tutorials for angularfire, there pretty good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.