Advertisement
Guest User

Untitled

a guest
Mar 27th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. {
  2. "users" : {
  3. "7fb5c5fd-34fe-47da-b5e9-f8faa23aea1c" : {
  4. "email" : "bl@bt.com",
  5. "firstname" : "bla",
  6. "lastname" : "bear",
  7. "uid" : "7fb5c5fd-34fe-47da-b5e9-f8faa23aea1c"
  8. },
  9. "d4d3e89f-ad51-4206-b347-e8273e2cbd78" : {
  10. "email" : "hey@t.com",
  11. "firstname" : "dfads",
  12. "lastname" : "dfsda",
  13. "uid" : "d4d3e89f-ad51-4206-b347-e8273e2cbd78"
  14. }
  15. }
  16. }
  17.  
  18. app.factory('Auth', ['rootRef', '$firebaseObject','$firebaseAuth', function (rootRef, $firebaseObject,$firebaseAuth) {
  19.  
  20. var auth = $firebaseAuth(rootRef);
  21. var user = new $firebaseObject;
  22.  
  23. auth.$onAuth(function (authData) {
  24. if (authData) {
  25. angular.copy(authData, user);
  26. // Set the profile
  27. user = $firebaseObject(rootRef.child('users').child(authData.uid));
  28. user.$loaded().then(function (user) {
  29. $window.localStorage['uid'] = user.uid.toString();
  30. $window.localStorage['profile'] = user;
  31. console.log('Window storage uid is' + $window.localStorage['uid']);
  32. });
  33. } else {
  34. if (user!=null) {
  35. user.$destroy();
  36. }
  37. }
  38. });
  39.  
  40. return {
  41. user: user,
  42. login: function (user) {
  43. return auth.$authWithPassword({
  44. email: user.email,
  45. password: user.password
  46. })
  47. },
  48. logout: function(auth) {
  49. return auth.$unauth;
  50. },
  51. signedIn: function (user) {
  52. return !!user.provider;
  53. }
  54. }
  55.  
  56.  
  57. }]);
  58.  
  59. ionic.bundle.js:25642 TypeError: Cannot read property 'ref' of undefined
  60.  
  61. Auth.$onAuth(function (AuthData) {
  62. if (AuthData === null) {
  63. console.log("Not logged in yet");
  64. } else {
  65. var uid = Auth.$getAuth().uid;
  66. var user = new Firebase(FirebaseUrl).child(users).child(uid).val();
  67. user.$loaded().then(function (profile) {
  68. $rootScope.user= profile;
  69. })
  70. });
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement