Turn off all references and API calls to github login if the feature is disabled
This commit is contained in:
parent
19a20a6c94
commit
badf002e92
6 changed files with 22 additions and 9 deletions
|
@ -3,7 +3,7 @@ import logging
|
||||||
from flask import request, redirect, url_for, Blueprint
|
from flask import request, redirect, url_for, Blueprint
|
||||||
from flask.ext.login import current_user
|
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 app import app, mixpanel
|
||||||
from data import model
|
from data import model
|
||||||
from util.names import parse_repository_name
|
from util.names import parse_repository_name
|
||||||
|
@ -11,6 +11,7 @@ from util.http import abort
|
||||||
from auth.permissions import AdministerRepositoryPermission
|
from auth.permissions import AdministerRepositoryPermission
|
||||||
from auth.auth import require_session_login
|
from auth.auth import require_session_login
|
||||||
|
|
||||||
|
import features
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ def get_github_user(token):
|
||||||
|
|
||||||
|
|
||||||
@callback.route('/github/callback', methods=['GET'])
|
@callback.route('/github/callback', methods=['GET'])
|
||||||
|
@route_show_if(features.GITHUB_LOGIN)
|
||||||
def github_oauth_callback():
|
def github_oauth_callback():
|
||||||
error = request.args.get('error', None)
|
error = request.args.get('error', None)
|
||||||
if error:
|
if error:
|
||||||
|
@ -101,6 +103,7 @@ def github_oauth_callback():
|
||||||
|
|
||||||
|
|
||||||
@callback.route('/github/callback/attach', methods=['GET'])
|
@callback.route('/github/callback/attach', methods=['GET'])
|
||||||
|
@route_show_if(features.GITHUB_LOGIN)
|
||||||
@require_session_login
|
@require_session_login
|
||||||
def github_oauth_attach():
|
def github_oauth_attach():
|
||||||
token = exchange_github_code_for_token(request.args.get('code'))
|
token = exchange_github_code_for_token(request.args.get('code'))
|
||||||
|
|
|
@ -6,12 +6,13 @@
|
||||||
placeholder="Password" ng-model="user.password">
|
placeholder="Password" ng-model="user.password">
|
||||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign In</button>
|
<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>
|
<i class="fa fa-circle"></i>
|
||||||
<span class="inner-text">OR</span>
|
<span class="inner-text">OR</span>
|
||||||
</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
|
<i class="fa fa-github fa-lg"></i> Sign In with GitHub
|
||||||
</a>
|
</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -8,14 +8,19 @@
|
||||||
match="newUser.password" required>
|
match="newUser.password" required>
|
||||||
<div class="form-group signin-buttons">
|
<div class="form-group signin-buttons">
|
||||||
<button class="btn btn-primary btn-block landing-signup-button" ng-disabled="signupForm.$invalid" type="submit"
|
<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>
|
analytics-on analytics-event="register">
|
||||||
<span class="social-alternate">
|
<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>
|
<i class="fa fa-circle"></i>
|
||||||
<span class="inner-text">OR</span>
|
<span class="inner-text">OR</span>
|
||||||
</span>
|
</span>
|
||||||
<a href="https://github.com/login/oauth/authorize?client_id={{ githubClientId }}&scope=user:email{{ github_state_clause }}"
|
<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>
|
class="btn btn-primary btn-block" quay-require="['GITHUB_LOGIN']">
|
||||||
<p class="help-block">No credit card required.</p>
|
<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>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div ng-show="registering" style="text-align: center">
|
<div ng-show="registering" style="text-align: center">
|
||||||
|
|
|
@ -1669,8 +1669,10 @@ quayApp.directive('signinForm', function () {
|
||||||
'signInStarted': '&signInStarted',
|
'signInStarted': '&signInStarted',
|
||||||
'signedIn': '&signedIn'
|
'signedIn': '&signedIn'
|
||||||
},
|
},
|
||||||
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService, CookieService) {
|
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService, CookieService, Features) {
|
||||||
$scope.showGithub = function() {
|
$scope.showGithub = function() {
|
||||||
|
if (!Features.GITHUB_LOGIN) { return; }
|
||||||
|
|
||||||
$scope.markStarted();
|
$scope.markStarted();
|
||||||
|
|
||||||
var mixpanelDistinctIdClause = '';
|
var mixpanelDistinctIdClause = '';
|
||||||
|
|
|
@ -1615,6 +1615,8 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use
|
||||||
}
|
}
|
||||||
|
|
||||||
UserService.updateUserIn($scope, function(user) {
|
UserService.updateUserIn($scope, function(user) {
|
||||||
|
if (!Features.GITHUB_LOGIN) { return; }
|
||||||
|
|
||||||
$scope.cuser = jQuery.extend({}, user);
|
$scope.cuser = jQuery.extend({}, user);
|
||||||
|
|
||||||
for (var i = 0; i < $scope.cuser.logins.length; i++) {
|
for (var i = 0; i < $scope.cuser.logins.length; i++) {
|
||||||
|
|
|
@ -160,7 +160,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Github tab -->
|
<!-- 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="loading" ng-show="!cuser">
|
||||||
<div class="quay-spinner 3x"></div>
|
<div class="quay-spinner 3x"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in a new issue