1yocktailApp.controller('SigninCtrl', function ($scope, $firebaseAuth, $location, Cocktail, $window) { 2 3 $scope.loading = false; 4 5 $scope.$on('$viewContentLoaded', function(){ 6 if(Cocktail.getUser() != ''){ 7 $location.path('/profile'); 8 }else{ 9 // do nothing 10 } 11 }); 12 13 // create authentication object 14 var firebaseObj = new Firebase("https://yocktail.firebaseio.com"); 15 var authObj = $firebaseAuth(firebaseObj); 16 17 // creating a Firebase database Reference for users 18 var usersRef = new Firebase("https://yocktail.firebaseio.com/web/data/users"); 19 20 $scope.SignIn = function(e) { 21 22 $scope.loading = true; 23 24 e.preventDefault(); 25 var email = $scope.user.email; 26 var password = $scope.user.password; 27 28 // signed in on firebase 29 authObj.$authWithPassword({ 30 email: email, 31 password: password 32 }) 33 .then(function(userData) { 34 //Success callback 35 console.log("SigninCtrl user"); 36 console.log(userData); 37 console.log('SigninCtrl Authentication successful with uid: ' + userData.uid); 38 39 // get the user's info from firebase 40 var uid = userData.uid; 41 usersRef.child(uid).once("value", function(data){ 42 console.log("SigninCtrl signin user data"); 43 console.log(data.val()); 44 var signinUser = data.val(); 45 signinUser.uid = uid; 46 //var signinUser = { uid: uid, name: signinUserData.name, bio: signinUserData.bio, email: signinUserData.email, birthday: signinUserData.birthday }; 47 Cocktail.setUser("user", signinUser); 48 49 console.log("user:" + Cocktail.getUser()); 50 51 // $location.path('/profile/'+uid); 52 $scope.loading = false; 53 54 $window.location.reload(); 55 //$scope.$apply(); 56 }); 57 }, function(error) { 58 //Failure callback 59 $scope.loading = false; 60 61 $scope.regError = true; 62 $scope.regErrorMessage = "Sorry, failed to sign in. Please try again."; 63 console.log('SigninCtrl Authentication failure'); 64 }); 65 }; 66 67});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.