From 90281fd7f0e751ca53f54b56e4de4e9a4eb81e76 Mon Sep 17 00:00:00 2001 From: Chaim Lev Ari Date: Fri, 25 Jan 2019 10:57:40 +0200 Subject: [PATCH] feat(oauth): add providers to providers-selector --- .../oauth-providers-selector.html | 4 ++-- .../oauth-providers-selector.js | 24 +++++++++++++++---- .../oauth-settings-controller.js | 15 ++++++++---- .../oauth-settings/oauth-settings.html | 2 +- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.html b/app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.html index 16879b0ac..f451768fe 100644 --- a/app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.html +++ b/app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.html @@ -9,9 +9,9 @@ class="form-control" id="oauth-provider-selector" ng-model="$ctrl.selectedProvider" - ng-options="provider as provider for provider in $ctrl.providers" + ng-change="$ctrl.onSelect($ctrl.selectedProvider)" + ng-options="provider as provider.name for provider in $ctrl.providers" > - diff --git a/app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.js b/app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.js index 9efd413b1..fa1cdb1e1 100644 --- a/app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.js +++ b/app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.js @@ -1,4 +1,20 @@ -angular.module('portainer.extensions.oauth') - .component('oauthProvidersSelector', { - templateUrl: 'app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.html' - }); \ No newline at end of file +angular.module('portainer.extensions.oauth').component('oauthProvidersSelector', { + templateUrl: 'app/extensions/oauth/components/oauth-providers-selector/oauth-providers-selector.html', + bindings: { + onSelect: '<' + }, + controller: function oauthProvidersSelectorController() { + this.providers = [ + { + name: 'Facebook', + authUrl: 'https://www.facebook.com/v3.2/dialog/oauth', + accessTokenUrl: 'https://graph.facebook.com/v3.2/oauth/access_token', + resourceUrl: 'https://graph.facebook.com/v3.2/me?fields=email', + userIdentifier: 'email' + }, + { + name: 'Custom' + } + ]; + } +}); diff --git a/app/extensions/oauth/components/oauth-settings/oauth-settings-controller.js b/app/extensions/oauth/components/oauth-settings/oauth-settings-controller.js index b91aabc6a..ba324c49b 100644 --- a/app/extensions/oauth/components/oauth-settings/oauth-settings-controller.js +++ b/app/extensions/oauth/components/oauth-settings/oauth-settings-controller.js @@ -1,6 +1,11 @@ angular.module('portainer.extensions.oauth') - .controller('OAuthSettingsController', function OAuthSettingsController() { - this.providers = [ - 'facebook' - ] - }); \ No newline at end of file +.controller('OAuthSettingsController', function OAuthSettingsController() { + this.onSelectProvider = onSelectProvider; + + function onSelectProvider(provider) { + this.settings.AuthorizationURI = provider.authUrl; + this.settings.AccessTokenURI = provider.accessTokenUrl; + this.settings.ResourceURI = provider.resourceUrl; + this.settings.UserIdentifier = provider.userIdentifier; + } +}); diff --git a/app/extensions/oauth/components/oauth-settings/oauth-settings.html b/app/extensions/oauth/components/oauth-settings/oauth-settings.html index f3307321d..e2a5217e0 100644 --- a/app/extensions/oauth/components/oauth-settings/oauth-settings.html +++ b/app/extensions/oauth/components/oauth-settings/oauth-settings.html @@ -1,5 +1,5 @@
- +
OAuth Configuration