netstix/public/js/controllers/loginController.js
2022-11-27 20:58:22 +08:00

22 lines
641 B
JavaScript

netstix.controller('LoginController', ['UserAuth', '$window', '$scope', function(UserAuth, $window, $scope) {
var self = this;
self.login = function() {
$scope.error = false;
$scope.disabled = true;
UserAuth.login($scope.loginForm.username, $scope.loginForm.password)
.then(function () {
$window.location.href ='/#/achievements';
$scope.disabled = false;
$scope.loginForm = {};
})
.catch(function () {
$scope.error = true;
$scope.errorMessage = "Invalid username and/or password";
$scope.disabled = false;
$scope.loginForm = {};
});
};
}]);