Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions src/app/users/sso-user-edit-dialog.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,9 @@ module.controller('users.SsoUserEditDialogController', [
// currently selected user object
$scope.user = user;

// These are the provider types accepted in the API.
$scope.providerTypes = [
'ad',
'adfs',
'auth0',
'behance',
'bitbucket',
'dribbble',
'facebook',
'github',
'google-oauth2',
'linkedin',
'samlp',
'sfdc',
'stackoverflow',
'twitter'
];

// true if details are being loaded/saved
// true if details are being loaded/saved
$scope.isLoading = false;

/**
* Close dialog
*/
Expand All @@ -48,10 +30,10 @@ module.controller('users.SsoUserEditDialogController', [
.then(function (data) {
$scope.user.profile = {};
if (data.profile) {
// we can't have all properties form profile as saving will fail.
// we can't have all properties form profile as saving will fail.
$scope.user.profile = {
userId: data.profile.userId,
providerType: data.profile.providerType,
name: data.profile.name,
provider: data.profile.provider
}
}
Expand Down Expand Up @@ -82,6 +64,23 @@ module.controller('users.SsoUserEditDialogController', [
});
}

/**
* Retrieves the SSO login providers.
*/
$scope.loadSsoProviders = function () {
UserService
.getSsoLoginProviders()
.then(function (data) {
$scope.providers = data.map(function (provider) {
return provider.name
});
})
.catch(function (error) {
$alert.error(error.error, $scope);
})
}

$scope.loadData();
$scope.loadSsoProviders();
}
]);
8 changes: 4 additions & 4 deletions src/app/users/sso-user-edit-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ <h4 class="modal-title" id="reg-dialog-label">SSO User</h4>
<label>User Id</label>
<input ng-model="user.profile.userId" type="text" class="form-control" name="userId" required>
</div>
<div class="form-group">
<label>Provider type </label>
<select ng-options="provider for provider in providerTypes" class="form-control" ng-model="user.profile.providerType" disabled></select>
<div class="form-group" ng-class="{'has-error': userForm.name.$touched && userForm.name.$invalid}">
<label>Name </label>
<input ng-model="user.profile.name" type="text" class="form-control" name="name">
</div>
<div class="form-group" ng-class="{'has-error': userForm.provider.$touched && userForm.provider.$invalid}">
<label>Provider</label>
<input ng-model="user.profile.provider" type="text" class="form-control" name="provider" required>
<select ng-options="provider for provider in providers" class="form-control" ng-model="user.profile.provider"></select>
</div>
</form>
</div>
Expand Down
22 changes: 22 additions & 0 deletions src/app/users/users.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,28 @@ angular.module('supportAdminApp')
helper.handleError
);
};

/**
* Get SSO login providers.
* @returns {Array} The SSO login providers.
*/
UserService.getSsoLoginProviders = function() {
var request = $http({
method: 'GET',
url: API_URL + '/v3/ssoLoginProviders',
headers: {
"Content-Type":"application/json"
}
});

return request.then(
function(response) {
$log.debug(response);
return response.data.result.content;
},
helper.handleError
);
};

return UserService;
}]);