title: Firebase Simple Login + Angular - Own data for each user
body: <p>This is my controller. Register function works ok. Login doesn't, but my question is, how can I make data for each user? For example, I have user john@doe.cz, UID is simplelogin:29, ID 29. Each user will have own accounts, categories, etc. So what is the best practice or how can I make it happen? I think about making own-firebase.firebaseio.com/users/(id, uid, or some kind of hash)/categories or accounts.</p>
  
  <pre><code>app.controller('AuthCtrl', function($scope, $ionicModal, $firebase, DataFactory){
  
      var auth = new FirebaseSimpleLogin(usersAuth, function(error, user) {
          if (error) {
              // an error occurred while attempting login
              console.log(error);
          } else if (user) {
              // user authenticated with Firebase
              console.log('User ID: ' + user.uid + ', Provider: ' + user.provider);
          } else {
              // user is logged out
          }
      });
  
      $ionicModal.fromTemplateUrl('views/auth/register.html', function(modal) {
          $scope.registerModal = modal;
      }, {
          scope: $scope,
          animation: 'slide-in-up'
      });
  
      $ionicModal.fromTemplateUrl('views/auth/login.html', function(modal) {
          $scope.loginModal = modal;
      }, {
          scope: $scope,
          animation: 'slide-in-up'
      });
  
      $scope.registerModalShow = function() {
          $scope.registerModal.show();
      };
  
      $scope.registerModalHide = function() {
          $scope.registerModal.hide();
      };
  
      $scope.loginModalShow = function() {
          $scope.loginModal.show();
      };
  
      $scope.loginModalHide = function() {
          $scope.loginModal.hide();
      };
  
      $scope.newUser = function(user){
          $scope.userEmail = user.email;
          $scope.userPassword = user.password;
  
          auth.createUser($scope.userEmail, $scope.userPassword, function(error, user) {
              if (!error) {
                  console.log('User UID: ' + user.uid + ', Email: ' + $scope.userEmail + ', User ID: ' + user.id + ', User Password: ' + $scope.userPassword);
              }
          });
  
          $scope.userRef = new Firebase(url + '/users' + $scope.userPassword);
          $scope.registerModalHide();
          user.email = '';
          user.password = '';
          alert($scope.userId);
      };
  
      $scope.userLogin = function(user){
          $scope.userLoginEmail = user.email;
          $scope.userLoginPassword = user.password;
  
          auth.login('password', {
              email: user.email,
              password: user.password
          });
          $scope.loginModalHide();
          user.email = '';
          user.password = '';
      };
  });
  </code></pre>