1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
app.factory('Auth', function(FIREBASE_URL, $firebaseAuth, $firebaseArray,$firebaseObject,$firebase, toaster,$location) {
var ref = new Firebase(FIREBASE_URL);
var auth = $firebaseAuth(ref);
var Auth = {
user: {},
/*Plusieurs fonctions...inutile pour lexemple*/
};
auth.$onAuth(function(authData) {
if(authData) {
angular.copy(authData, Auth.user);
Auth.user.profile = $firebaseObject(ref.child('profileExt').child(authData.uid));
console.log(Auth.user.profile);
} else {
if(Auth.user && Auth.user.profile) {
Auth.user.profile.$destroy();
}
angular.copy({}, Auth.user);
}
}); |