Turn off all references and API calls to github login if the feature is disabled

This commit is contained in:
Joseph Schorr 2014-04-06 00:50:30 -04:00
parent 19a20a6c94
commit badf002e92
6 changed files with 22 additions and 9 deletions

View file

@ -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'))

View file

@ -6,12 +6,13 @@
placeholder="Password" ng-model="user.password">
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign In</button>
<span class="social-alternate">
<span class="social-alternate" quay-require="['GITHUB_LOGIN']">
<i class="fa fa-circle"></i>
<span class="inner-text">OR</span>
</span>
<a id="github-signin-link" class="btn btn-primary btn-lg btn-block" href="javascript:void(0)" ng-click="showGithub()">
<a id="github-signin-link" class="btn btn-primary btn-lg btn-block" href="javascript:void(0)" ng-click="showGithub()"
quay-require="['GITHUB_LOGIN']">
<i class="fa fa-github fa-lg"></i> Sign In with GitHub
</a>
</form>

View file

@ -8,14 +8,19 @@
match="newUser.password" required>
<div class="form-group signin-buttons">
<button class="btn btn-primary btn-block landing-signup-button" ng-disabled="signupForm.$invalid" type="submit"
analytics-on analytics-event="register">Sign Up for Free!</button>
<span class="social-alternate">
analytics-on analytics-event="register">
<span quay-show="Features.BILLING">Sign Up for Free!</span>
<span quay-show="!Features.BILLING">Sign Up</span>
</button>
<span class="social-alternate" quay-require="['GITHUB_LOGIN']">
<i class="fa fa-circle"></i>
<span class="inner-text">OR</span>
</span>
<a href="https://github.com/login/oauth/authorize?client_id={{ githubClientId }}&scope=user:email{{ github_state_clause }}"
class="btn btn-primary btn-block"><i class="fa fa-github fa-lg"></i> Sign In with GitHub</a>
<p class="help-block">No credit card required.</p>
class="btn btn-primary btn-block" quay-require="['GITHUB_LOGIN']">
<i class="fa fa-github fa-lg"></i> Sign In with GitHub
</a>
<p class="help-block" quay-require="['BILLING']">No credit card required.</p>
</div>
</form>
<div ng-show="registering" style="text-align: center">

View file

@ -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 = '';

View file

@ -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++) {

View file

@ -160,7 +160,7 @@
</div>
<!-- Github tab -->
<div id="github" class="tab-pane">
<div id="github" class="tab-pane" quay-require="['GITHUB_LOGIN']">
<div class="loading" ng-show="!cuser">
<div class="quay-spinner 3x"></div>
</div>