From b4940855e8f9a61f259fe086f6607542bc84b0a9 Mon Sep 17 00:00:00 2001 From: Vincent Fiduccia Date: Tue, 13 Jan 2015 15:21:23 -0700 Subject: [PATCH] Access Control config enhancements - Check Github API and automatically remove users/orgs that don't exist - Saving/Saved state on the authorization save button to show state - Waiting state on test button to show state - Size GitHub popup window bigger to show content --- app/initializers/authentication.js | 4 +- .../components/github-avatar/component.js | 17 +++-- .../components/github-avatar/template.hbs | 2 +- app/pods/components/page-header/template.hbs | 9 ++- app/pods/login/controller.js | 2 +- app/pods/settings/auth/controller.js | 73 +++++++++++++++---- app/pods/settings/auth/route.js | 4 + app/pods/settings/auth/template.hbs | 60 +++++++++------ app/pods/settings/route.js | 3 + app/styles/layout.scss | 3 +- package.json | 4 +- 11 files changed, 127 insertions(+), 54 deletions(-) diff --git a/app/initializers/authentication.js b/app/initializers/authentication.js index 541a53007..1bd4a2f41 100644 --- a/app/initializers/authentication.js +++ b/app/initializers/authentication.js @@ -8,8 +8,8 @@ export function initialize(container, application) { // Find out if auth is enabled store.rawRequest({ - url: 'token', // Base url, which will be /v1 - headers: { 'authorization': undefined } + url: 'token', + headers: { 'authorization': undefined } // Explicitly not send the auth token }) .then(function(obj) { var body = JSON.parse(obj.xhr.responseText); diff --git a/app/pods/components/github-avatar/component.js b/app/pods/components/github-avatar/component.js index 29ee2eb2f..461bb982f 100644 --- a/app/pods/components/github-avatar/component.js +++ b/app/pods/components/github-avatar/component.js @@ -5,21 +5,24 @@ export default Ember.Component.extend({ login: null, classNames: ['gh-avatar'], - name: 'Loading...', + name: 'Checking...', avatarUrl: null, nameChanged: function() { var self = this; - var url = 'https://api.github.com/' + this.get('type') + 's/' + this.get('login') + '?s=40'; + var login = this.get('login'); + var type = this.get('type'); + var url = 'https://api.github.com/' + type + 's/' + login; Ember.$.ajax({url: url, dataType: 'json'}).then(function(body) { self.set('name', body.name); - self.set('avatarUrl', body.avatar_url); - }, function() { - var type = self.get('type'); - type = type.substr(0,1).toUpperCase() + type.substr(1); - self.set('name', 'Warning: ' + type + ' not found'); + var avatarUrl = body.avatar_url; + avatarUrl += (avatarUrl.indexOf('?') >= 0 ? '&' : '?') + 's=40'; + self.set('avatarUrl', avatarUrl); + }, function() { + self.set('name', '(Not found)'); + self.sendAction('notFound', login); }); }.observes('login','type').on('init'), diff --git a/app/pods/components/github-avatar/template.hbs b/app/pods/components/github-avatar/template.hbs index eb63daac8..c58fddb5e 100644 --- a/app/pods/components/github-avatar/template.hbs +++ b/app/pods/components/github-avatar/template.hbs @@ -12,5 +12,5 @@
{{login}}
-
{{name}}
+
{{#if name}}{{name}}{{else}}No name{{/if}}
diff --git a/app/pods/components/page-header/template.hbs b/app/pods/components/page-header/template.hbs index c7acfbaf8..e5f5d9bf6 100644 --- a/app/pods/components/page-header/template.hbs +++ b/app/pods/components/page-header/template.hbs @@ -2,9 +2,12 @@ {{#if app.authenticationEnabled}}