Advertisement
Guest User

Untitled

a guest
Apr 25th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <button type="button" class="btn btn-info" ng-click="openModal('md')">E-mail & password</button>
  2.  
  3. $scope.openModal = function(size) {
  4. var modalInstance = $uibModal.open({
  5. templateUrl: 'javascript/templates/emailLoginModalContent.html',
  6. controller: 'EmailLoginModalInstanceCtrl',
  7. scope: $scope,
  8. size: size
  9. });
  10. };
  11.  
  12. app.controller('EmailLoginModalInstanceCtrl', ['$scope', '$uibModalInstance', '$firebaseAuth', function($scope, $uibModalInstance, $firebaseAuth) {
  13. console.log("EmailLoginModalInstanceCtrl controller.");
  14.  
  15. var ref = new Firebase("https://my-firebase.firebaseio.com/");
  16. $scope.authObj = $firebaseAuth(ref);
  17.  
  18. // Login user
  19.  
  20. $scope.loginUser = function(user) {
  21. ref.authWithPassword({
  22. email: $scope.user.email,
  23. password: $scope.user.password
  24. }, function(error, authData) {
  25. if (error) {
  26. console.log("Login Failed!", error);
  27. } else {
  28. console.log("Authenticated successfully with payload:", authData);
  29. $scope.authData = authData;
  30. $scope.authData.uid = authData.uid;
  31. console.log($scope.authData.uid);
  32. $scope.reset();
  33. $scope.cancel();
  34. $scope.$apply(function() {
  35. console.log("Applied!");
  36. });
  37. }
  38. });
  39. };
  40.  
  41. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement