Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "users" : {
- "7fb5c5fd-34fe-47da-b5e9-f8faa23aea1c" : {
- "email" : "bl@bt.com",
- "firstname" : "bla",
- "lastname" : "bear",
- "uid" : "7fb5c5fd-34fe-47da-b5e9-f8faa23aea1c"
- },
- "d4d3e89f-ad51-4206-b347-e8273e2cbd78" : {
- "email" : "hey@t.com",
- "firstname" : "dfads",
- "lastname" : "dfsda",
- "uid" : "d4d3e89f-ad51-4206-b347-e8273e2cbd78"
- }
- }
- }
- app.factory('Auth', ['rootRef', '$firebaseObject','$firebaseAuth', function (rootRef, $firebaseObject,$firebaseAuth) {
- var auth = $firebaseAuth(rootRef);
- var user = new $firebaseObject;
- auth.$onAuth(function (authData) {
- if (authData) {
- angular.copy(authData, user);
- // Set the profile
- user = $firebaseObject(rootRef.child('users').child(authData.uid));
- user.$loaded().then(function (user) {
- $window.localStorage['uid'] = user.uid.toString();
- $window.localStorage['profile'] = user;
- console.log('Window storage uid is' + $window.localStorage['uid']);
- });
- } else {
- if (user!=null) {
- user.$destroy();
- }
- }
- });
- return {
- user: user,
- login: function (user) {
- return auth.$authWithPassword({
- email: user.email,
- password: user.password
- })
- },
- logout: function(auth) {
- return auth.$unauth;
- },
- signedIn: function (user) {
- return !!user.provider;
- }
- }
- }]);
- ionic.bundle.js:25642 TypeError: Cannot read property 'ref' of undefined
- Auth.$onAuth(function (AuthData) {
- if (AuthData === null) {
- console.log("Not logged in yet");
- } else {
- var uid = Auth.$getAuth().uid;
- var user = new Firebase(FirebaseUrl).child(users).child(uid).val();
- user.$loaded().then(function (profile) {
- $rootScope.user= profile;
- })
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement