angular.module('Auth').controller("LoginController", [ "$scope", "$location", "$window", "AuthSvc", function($scope, $location, $window, AuthSvc) { $scope.userInfo = AuthSvc; $scope.login = function() { AuthSvc.login($scope.username, $scope.password).then(function(result) { $scope.userInfo = result; // alert('Test'); // if (typeof $scope.userInfo === "undefined") // alert("TURKEY!"); // if (typeof $scope.userInfo.authenticated === "undefined") // alert("TURKEY!2"); // else // alert("TURKEY!2.1: " + $scope.userInfo.authenticated); if ($scope.userInfo.authenticated === true) $location.path("/"); else { $scope.error = "Invalid Credentials"; $scope.dataLoading = false; // $window.alert("Invalid credentials"); } }, function(error) { $scope.error = "Invalid Credentials"; $scope.dataLoading = false; // $window.alert("Invalid credentials"); console.log(error); }); }; $scope.cancel = function() { $scope.username = ""; $scope.password = ""; }; } ]);