From 4282977e902eb4ef2fb08d4ddb5bcdeac0636e71 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 4 Jun 2014 16:08:26 -0400 Subject: [PATCH 1/3] Check on the builds array; it may not be present if the page has changed or the builds have not yet loaded --- static/js/controllers.js | 4 ++++ 1 file changed, 4 insertions(+) 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); }); From 738c4a86ffe2921609fc7dede608cf008afed9c5 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 4 Jun 2014 16:12:31 -0400 Subject: [PATCH 2/3] Check to make sure we can load the github user data --- endpoints/callbacks.py | 5 +++++ 1 file changed, 5 insertions(+) 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) From bbb48b12352e39fc9abe359931f4916d3dafb5fd Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 4 Jun 2014 16:27:45 -0400 Subject: [PATCH 3/3] Handle the case where the plans do not load correctly. --- static/js/app.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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([]); }); };