Merge branch 'githublogin'
This commit is contained in:
commit
a3bd2a065a
3 changed files with 8 additions and 7 deletions
|
@ -21,11 +21,11 @@ client = app.config['HTTPCLIENT']
|
||||||
callback = Blueprint('callback', __name__)
|
callback = Blueprint('callback', __name__)
|
||||||
|
|
||||||
|
|
||||||
def exchange_github_code_for_token(code):
|
def exchange_github_code_for_token(code, for_login=True):
|
||||||
code = request.args.get('code')
|
code = request.args.get('code')
|
||||||
payload = {
|
payload = {
|
||||||
'client_id': app.config['GITHUB_CLIENT_ID'],
|
'client_id': app.config['GITHUB_LOGIN_CLIENT_ID' if for_login else 'GITHUB_CLIENT_ID'],
|
||||||
'client_secret': app.config['GITHUB_CLIENT_SECRET'],
|
'client_secret': app.config['GITHUB_LOGIN_CLIENT_SECRET' if for_login else 'GITHUB_CLIENT_SECRET'],
|
||||||
'code': code,
|
'code': code,
|
||||||
}
|
}
|
||||||
headers = {
|
headers = {
|
||||||
|
@ -120,7 +120,7 @@ def github_oauth_attach():
|
||||||
def attach_github_build_trigger(namespace, repository):
|
def attach_github_build_trigger(namespace, repository):
|
||||||
permission = AdministerRepositoryPermission(namespace, repository)
|
permission = AdministerRepositoryPermission(namespace, repository)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
token = exchange_github_code_for_token(request.args.get('code'))
|
token = exchange_github_code_for_token(request.args.get('code'), for_login=False)
|
||||||
repo = model.get_repository(namespace, repository)
|
repo = model.get_repository(namespace, repository)
|
||||||
if not repo:
|
if not repo:
|
||||||
msg = 'Invalid repository: %s/%s' % (namespace, repository)
|
msg = 'Invalid repository: %s/%s' % (namespace, repository)
|
||||||
|
|
|
@ -937,6 +937,7 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
||||||
keyService['githubClientId'] = Config['GITHUB_CLIENT_ID'];
|
keyService['githubClientId'] = Config['GITHUB_CLIENT_ID'];
|
||||||
keyService['githubLoginClientId'] = Config['GITHUB_LOGIN_CLIENT_ID'];
|
keyService['githubLoginClientId'] = Config['GITHUB_LOGIN_CLIENT_ID'];
|
||||||
keyService['githubRedirectUri'] = Config.getUrl('/oauth2/github/callback');
|
keyService['githubRedirectUri'] = Config.getUrl('/oauth2/github/callback');
|
||||||
|
|
||||||
return keyService;
|
return keyService;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
@ -1814,7 +1815,7 @@ quayApp.directive('signinForm', function () {
|
||||||
// Needed to ensure that UI work done by the started callback is finished before the location
|
// Needed to ensure that UI work done by the started callback is finished before the location
|
||||||
// changes.
|
// changes.
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
var url = 'https://github.com/login/oauth/authorize?client_id=' + encodeURIComponent(KeyService.githubClientId) +
|
var url = 'https://github.com/login/oauth/authorize?client_id=' + encodeURIComponent(KeyService.githubLoginClientId) +
|
||||||
'&scope=user:email' + mixpanelDistinctIdClause;
|
'&scope=user:email' + mixpanelDistinctIdClause;
|
||||||
document.location = url;
|
document.location = url;
|
||||||
}, 250);
|
}, 250);
|
||||||
|
@ -1879,7 +1880,7 @@ quayApp.directive('signupForm', function () {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.githubClientId = KeyService.githubClientId;
|
$scope.githubClientId = KeyService.githubLoginClientId;
|
||||||
|
|
||||||
$scope.awaitingConfirmation = false;
|
$scope.awaitingConfirmation = false;
|
||||||
$scope.registering = false;
|
$scope.registering = false;
|
||||||
|
|
|
@ -1622,7 +1622,7 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use
|
||||||
$scope.convertStep = 0;
|
$scope.convertStep = 0;
|
||||||
$scope.org = {};
|
$scope.org = {};
|
||||||
$scope.githubRedirectUri = KeyService.githubRedirectUri;
|
$scope.githubRedirectUri = KeyService.githubRedirectUri;
|
||||||
$scope.githubClientId = KeyService.githubClientId;
|
$scope.githubClientId = KeyService.githubLoginClientId;
|
||||||
$scope.authorizedApps = null;
|
$scope.authorizedApps = null;
|
||||||
|
|
||||||
$scope.logsShown = 0;
|
$scope.logsShown = 0;
|
||||||
|
|
Reference in a new issue