diff options
Diffstat (limited to 'app/login')
-rw-r--r-- | app/login/controllers/login-controller.js | 89 | ||||
-rw-r--r-- | app/login/index.js | 34 |
2 files changed, 62 insertions, 61 deletions
diff --git a/app/login/controllers/login-controller.js b/app/login/controllers/login-controller.js index 594d3a1..03bbc15 100644 --- a/app/login/controllers/login-controller.js +++ b/app/login/controllers/login-controller.js @@ -6,53 +6,54 @@ * @name LoginController */ -window.angular && (function (angular) { - 'use strict'; +window.angular && (function(angular) { + 'use strict'; - angular - .module('app.login') - .controller('LoginController', [ - '$scope', - '$window', - 'APIUtils', - 'dataService', - 'userModel', - '$routeParams', - function($scope, $window, APIUtils, dataService, userModel, $routeParams){ - $scope.dataService = dataService; - $scope.host = $scope.dataService.host.replace(/^https?\:\/\//ig, ''); + angular + .module('app.login') + .controller('LoginController', [ + '$scope', + '$window', + 'APIUtils', + 'dataService', + 'userModel', + '$routeParams', + function($scope, $window, APIUtils, dataService, userModel, $routeParams) { + $scope.dataService = dataService; + $scope.host = $scope.dataService.host.replace(/^https?\:\/\//ig, ''); - $scope.tryLogin = function(host, username, password, event){ - if(event.keyCode === 13){ - $scope.login(host, username, password); - } - }; - $scope.login = function(host, username, password){ - $scope.error = false; - $scope.description = false; + $scope.tryLogin = function(host, username, password, event) { + if (event.keyCode === 13) { + $scope.login(host, username, password); + } + }; + $scope.login = function(host, username, password) { + $scope.error = false; + $scope.description = false; - if(!username || username == "" || - !password || password == "" || - !host || host == "" - ){ - return false; - }else{ - $scope.dataService.setHost(host); - userModel.login(username, password, function(status, description){ - if(status){ - $scope.$emit('user-logged-in',{}); - $window.location.hash = '#/overview/server'; - }else{ - $scope.error = true; - if(description){ - $scope.description = description; - } - }; - }); - } + if (!username || username == '' || + !password || password == '' || + !host || host == '' + ) { + return false; + } + else { + $scope.dataService.setHost(host); + userModel.login(username, password, function(status, description) { + if (status) { + $scope.$emit('user-logged-in', {}); + $window.location.hash = '#/overview/server'; + } + else { + $scope.error = true; + if (description) { + $scope.description = description; } - } - ] - ); + } + }); + } + }; + } + ]); })(angular); diff --git a/app/login/index.js b/app/login/index.js index 8867065..04343f5 100644 --- a/app/login/index.js +++ b/app/login/index.js @@ -5,23 +5,23 @@ * @exports app/login/index */ -window.angular && (function (angular) { - 'use strict'; +window.angular && (function(angular) { + 'use strict'; - angular - .module('app.login', [ - 'ngRoute', - 'app.constants', - 'app.common.services' - ]) - // Route configuration - .config(['$routeProvider', function ($routeProvider) { - $routeProvider - .when('/login', { - 'template': require('./controllers/login-controller.html'), - 'controller': 'LoginController', - authenticated: false - }); - }]); + angular + .module('app.login', [ + 'ngRoute', + 'app.constants', + 'app.common.services' + ]) + // Route configuration + .config(['$routeProvider', function($routeProvider) { + $routeProvider + .when('/login', { + 'template': require('./controllers/login-controller.html'), + 'controller': 'LoginController', + authenticated: false + }); + }]); })(window.angular); |