feat(authentication-settings): add default port when not set in url (#1456)

pull/1470/head
Miguel A. C 2017-12-04 19:41:59 +01:00 committed by Anthony Lapenna
parent 406757d751
commit d8f6b14726
1 changed files with 11 additions and 2 deletions

View File

@ -32,6 +32,7 @@ function ($q, $scope, Notifications, SettingsService, FileUploadService) {
$scope.state.connectivityCheckInProgress = true;
$q.when(!uploadRequired || FileUploadService.uploadLDAPTLSFiles(TLSCAFile, null, null))
.then(function success(data) {
addLDAPDefaultPort(settings, $scope.LDAPSettings.TLSConfig.TLS);
return SettingsService.checkLDAPConnectivity(settings);
})
.then(function success(data) {
@ -60,6 +61,7 @@ function ($q, $scope, Notifications, SettingsService, FileUploadService) {
$scope.state.actionInProgress = true;
$q.when(!uploadRequired || FileUploadService.uploadLDAPTLSFiles(TLSCAFile, null, null))
.then(function success(data) {
addLDAPDefaultPort(settings, $scope.LDAPSettings.TLSConfig.TLS);
return SettingsService.update(settings);
})
.then(function success(data) {
@ -74,6 +76,13 @@ function ($q, $scope, Notifications, SettingsService, FileUploadService) {
});
};
// Add default port if :port is not defined in URL
function addLDAPDefaultPort(settings, tlsEnabled) {
if (settings.LDAPSettings.URL.indexOf(':') === -1) {
settings.LDAPSettings.URL += tlsEnabled ? ':636' : ':389';
}
}
function initView() {
SettingsService.settings()
.then(function success(data) {