/**
 * Authentication Controller
 */

angular
  .module('teamform')
  .controller("AuthCtrl", ["$scope", "$firebaseAuth", "$state", "Auth",

  function($scope, $firebaseAuth, $state, Auth) {
    $scope.auth = Auth;
    $scope.email = null;
    $scope.password = null;
    $scope.confirmPassword = null;
    $scope.errorMessage = null;

    $scope.signIn = function() {
      $scope.firebaseUser = null;
      $scope.error = null;
      $scope.errorMessage = null;

      $firebaseAuth().$signInWithEmailAndPassword($scope.email, $scope.password).then(function(firebaseUser) {
        //success
        $scope.firebaseUser = firebaseUser;
      }).catch(function(error) {
        // Handle Errors here.
        $scope.errorCode = error.code;
        $scope.errorMessage = error.message;
      });

    };

    $scope.signInWithPopup = function(provider) {
      $scope.firebaseUser = null;
      $scope.error = null;
      $scope.errorMessage = null;

      switch(provider) {
        case "facebook":
          provider = new firebase.auth.FacebookAuthProvider();
          break;
        case "google":
          provider = new firebase.auth.GoogleAuthProvider();
          break;
        case "github":
          provider = new firebase.auth.GithubAuthProvider();
      }

      $firebaseAuth().$signInWithPopup( provider ).then(function(firebaseUser) {
        //success
        $scope.firebaseUser = firebaseUser;
      }).catch(function(error) {
        // Handle Errors here.
        $scope.errorCode = error.code;
        $scope.errorMessage = error.message;
      });
    };

    $scope.createUser = function() {
      $scope.message = null;
      $scope.error = null;
      $scope.errorMessage = null;

      if($scope.password !== $scope.confirmPassword) {
        $scope.errorMessage = "Confirm Password is different form password!";
        return;
      }

      // Create a new user
      Auth.$createUserWithEmailAndPassword($scope.email, $scope.password)
        .then(function(firebaseUser) {
          $scope.message = "User created!";
          firebaseUser.updateProfile({
            displayName: $scope.name
          });
        }).catch(function(error) {
          $scope.errorCode = error.code;
          $scope.errorMessage = error.message;
        });
    };

    // $scope.deleteUser = function() {
    //   $scope.message = null;
    //   $scope.error = null;
    //   $scope.errorMessage = null;

    //   // Delete the currently signed-in user
    //   Auth.$deleteUser().then(function() {
    //     $scope.message = "User deleted";
    //   }).catch(function(error) {
    //     $scope.error = error;
    //   });
    // };

  }
]);
@@ -954,14 +954,10 @@
     
-switch
+if
 (pro
@@ -965,24 +965,12 @@
 ider
-) %7B%0A        case
+ ===
  %22fa
@@ -976,20 +976,20 @@
 acebook%22
-:%0A  
+) %7B%0A
         
@@ -1047,39 +1047,38 @@
 ;%0A      
-    break;%0A        case
+%7Delse if (provider ===
  %22google
@@ -1078,20 +1078,20 @@
 %22google%22
-:%0A  
+) %7B%0A
         
@@ -1151,31 +1151,30 @@
     
-    break;%0A        case
+%7Delse if (provider ===
  %22gi
@@ -1182,12 +1182,12 @@
 hub%22
-:%0A  
+) %7B%0A
     

change switch provider to if-else statement