Improve JavaScript of SOGoRootPage module

This commit is contained in:
Francis Lachapelle
2014-08-06 15:26:52 -04:00
parent 773675519f
commit fc2acebd17
3 changed files with 192 additions and 47 deletions

View File

@@ -1,45 +1,23 @@
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* JavaScript for SOGoContacts */
/* JavaScript for SOGoRootPage */
'use strict';
(function() {
'use strict';
var SOGoRootPageApp = angular.module('SOGoRootPage', ['SOGoAuthentication']);
angular.module('SOGo.RootPage', ['SOGo.Authentication'])
SOGoRootPageApp.controller('loginController', ['$scope', '$http', 'SOGoAuthentication', function($scope, $http, SOGoAuthentication) {
$scope.warning = false;
$scope.login = function($event) {
//$event.stopPropagation();
.controller('loginController', ['$scope', 'Authentication', function($scope, Authentication) {
$scope.warning = false;
var username = $scope.username,
password = $scope.password,
domain = $scope.domain,
language,
rememberLogin = $scope.rememberLogin ? 1 : 0;
if ($scope.loginSuffix && !username.endsWith($scope.loginSuffix)) {
username += loginSuffix;
domain = false;
}
if ($scope.language && $scope.language != 'WONoSelectionString') {
language = $scope.language;
}
SOGoAuthentication.login(username, password, domain, language, rememberLogin)
.then(function(url) {
window.location.href = url;
}, function(msg) {
$scope.warning = msg;
});
// $http({
// method: 'POST',
// url: 'http://debian.inverse.ca/SOGo/connect',
// params: postData})
// .success(function(data, status, headers, config) {
// alert('success: ' + status);
// }).error(function(data, status, headers, config) {
// alert('error: ' + status);
// });
return false;
};
}]);
$scope.creds = { 'username': null, 'password': null };
$scope.login = function(creds) {
$scope.warning = false;
Authentication.login(creds)
.then(function(url) {
window.location.href = url;
}, function(msg) {
$scope.warning = msg.error;
});
return false;
};
}]);
})();