diff --git a/endpoints/callbacks.py b/endpoints/callbacks.py index 9727d8847..015f3c3a7 100644 --- a/endpoints/callbacks.py +++ b/endpoints/callbacks.py @@ -61,6 +61,8 @@ def github_oauth_callback(): token = exchange_github_code_for_token(request.args.get('code')) user_data = get_github_user(token) + if not user_data: + return render_page_template('githuberror.html', error_message='Could not load user data') username = user_data['login'] github_id = user_data['id'] @@ -112,6 +114,9 @@ def github_oauth_callback(): def github_oauth_attach(): token = exchange_github_code_for_token(request.args.get('code')) user_data = get_github_user(token) + if not user_data: + return render_page_template('githuberror.html', error_message='Could not load user data') + github_id = user_data['id'] user_obj = current_user.db_user() model.attach_federated_login(user_obj, 'github', github_id) diff --git a/static/js/app.js b/static/js/app.js index 86f915723..397729c3b 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1093,20 +1093,17 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading planService.verifyLoaded = function(callback) { if (!Features.BILLING) { return; } - if (plans) { + if (plans && plans.length) { callback(plans); return; } ApiService.listPlans().then(function(data) { - var i = 0; - for(i = 0; i < data.plans.length; i++) { - planDict[data.plans[i].stripeId] = data.plans[i]; - } - plans = data.plans; - if (plans) { - callback(plans); + plans = data.plans || []; + for(var i = 0; i < plans.length; i++) { + planDict[plans[i].stripeId] = plans[i]; } + callback(plans); }, function() { callback([]); }); }; diff --git a/static/js/controllers.js b/static/js/controllers.js index 67cb99ac4..1bb907bb0 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -942,6 +942,8 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope }; $scope.handleBuildStarted = function(newBuild) { + if (!$scope.builds) { return; } + $scope.builds.unshift(newBuild); $scope.setCurrentBuild(newBuild['id'], true); }; @@ -980,6 +982,8 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope }; ApiService.requestRepoBuild(data, params).then(function(newBuild) { + if (!$scope.builds) { return; } + $scope.builds.unshift(newBuild); $scope.setCurrentBuild(newBuild['id'], true); });