This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/external-logins-manager.js
Joseph Schorr c0286d1ac3 Add support for Dex to Quay
Fixes #306

- Adds support for Dex as an OAuth external login provider
- Adds support for OIDC in general
- Extract out external logins on the JS side into a service
- Add a feature flag for disabling direct login
- Add support for directing to the single external login service
- Does *not* yet support the config in the superuser tool
2015-09-04 17:05:06 -04:00

51 lines
No EOL
1.6 KiB
JavaScript

/**
* Element for managing the applications authorized by a user.
*/
angular.module('quay').directive('externalLoginsManager', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/external-logins-manager.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
'user': '=user',
},
controller: function($scope, $element, ApiService, UserService, Features, Config, KeyService,
ExternalLoginService) {
$scope.Features = Features;
$scope.Config = Config;
$scope.KeyService = KeyService;
$scope.EXTERNAL_LOGINS = ExternalLoginService.EXTERNAL_LOGINS;
$scope.externalLoginInfo = {};
$scope.hasSingleSignin = ExternalLoginService.hasSingleSignin();
UserService.updateUserIn($scope, function(user) {
$scope.cuser = jQuery.extend({}, user);
$scope.externalLoginInfo = {};
if ($scope.cuser.logins) {
for (var i = 0; i < $scope.cuser.logins.length; i++) {
var login = $scope.cuser.logins[i];
login.metadata = login.metadata || {};
$scope.externalLoginInfo[login.service] = login;
}
}
});
$scope.detachExternalLogin = function(kind) {
if (!Features.DIRECT_LOGIN) { return; }
var params = {
'servicename': kind
};
ApiService.detachExternalLogin(null, params).then(function() {
UserService.load();
}, ApiService.errorDisplay('Count not detach service'));
};
}
};
return directiveDefinitionObject;
});