From badf002e92e5ad5283574ebd2a1ea001f0be615b Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Sun, 6 Apr 2014 00:50:30 -0400 Subject: [PATCH] Turn off all references and API calls to github login if the feature is disabled --- endpoints/callbacks.py | 5 ++++- static/directives/signin-form.html | 5 +++-- static/directives/signup-form.html | 13 +++++++++---- static/js/app.js | 4 +++- static/js/controllers.js | 2 ++ static/partials/user-admin.html | 2 +- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/endpoints/callbacks.py b/endpoints/callbacks.py index 0f110c098..2f801af88 100644 --- a/endpoints/callbacks.py +++ b/endpoints/callbacks.py @@ -3,7 +3,7 @@ import logging from flask import request, redirect, url_for, Blueprint from flask.ext.login import current_user -from endpoints.common import render_page_template, common_login +from endpoints.common import render_page_template, common_login, route_show_if from app import app, mixpanel from data import model from util.names import parse_repository_name @@ -11,6 +11,7 @@ from util.http import abort from auth.permissions import AdministerRepositoryPermission from auth.auth import require_session_login +import features logger = logging.getLogger(__name__) @@ -48,6 +49,7 @@ def get_github_user(token): @callback.route('/github/callback', methods=['GET']) +@route_show_if(features.GITHUB_LOGIN) def github_oauth_callback(): error = request.args.get('error', None) if error: @@ -101,6 +103,7 @@ def github_oauth_callback(): @callback.route('/github/callback/attach', methods=['GET']) +@route_show_if(features.GITHUB_LOGIN) @require_session_login def github_oauth_attach(): token = exchange_github_code_for_token(request.args.get('code')) diff --git a/static/directives/signin-form.html b/static/directives/signin-form.html index 814955ce6..f56b8f8db 100644 --- a/static/directives/signin-form.html +++ b/static/directives/signin-form.html @@ -6,12 +6,13 @@ placeholder="Password" ng-model="user.password"> - + - + Sign In with GitHub diff --git a/static/directives/signup-form.html b/static/directives/signup-form.html index 562223d96..0e87f17e5 100644 --- a/static/directives/signup-form.html +++ b/static/directives/signup-form.html @@ -8,14 +8,19 @@ match="newUser.password" required>
diff --git a/static/js/app.js b/static/js/app.js index 4c60e1c4d..b2e5e213c 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1669,8 +1669,10 @@ quayApp.directive('signinForm', function () { 'signInStarted': '&signInStarted', 'signedIn': '&signedIn' }, - controller: function($scope, $location, $timeout, ApiService, KeyService, UserService, CookieService) { + controller: function($scope, $location, $timeout, ApiService, KeyService, UserService, CookieService, Features) { $scope.showGithub = function() { + if (!Features.GITHUB_LOGIN) { return; } + $scope.markStarted(); var mixpanelDistinctIdClause = ''; diff --git a/static/js/controllers.js b/static/js/controllers.js index 33b17772f..a7db3090c 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -1615,6 +1615,8 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use } UserService.updateUserIn($scope, function(user) { + if (!Features.GITHUB_LOGIN) { return; } + $scope.cuser = jQuery.extend({}, user); for (var i = 0; i < $scope.cuser.logins.length; i++) { diff --git a/static/partials/user-admin.html b/static/partials/user-admin.html index 0a0bb1f82..15cd5cd20 100644 --- a/static/partials/user-admin.html +++ b/static/partials/user-admin.html @@ -160,7 +160,7 @@
-
+