- Handle the case when the user is not logged in on the oath form
- Have the sign in form properly redirect back to the current page for GitHub login
This commit is contained in:
parent
8ac67e3061
commit
8f3b87c866
2 changed files with 33 additions and 8 deletions
|
@ -353,7 +353,8 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu
|
||||||
return cookieService;
|
return cookieService;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
$provide.factory('UserService', ['ApiService', 'CookieService', function(ApiService, CookieService) {
|
$provide.factory('UserService', ['ApiService', 'CookieService', '$rootScope',
|
||||||
|
function(ApiService, CookieService, $rootScope) {
|
||||||
var userResponse = {
|
var userResponse = {
|
||||||
verified: false,
|
verified: false,
|
||||||
anonymous: true,
|
anonymous: true,
|
||||||
|
@ -457,6 +458,9 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu
|
||||||
return userResponse;
|
return userResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Update the user in the root scope.
|
||||||
|
userService.updateUserIn($rootScope);
|
||||||
|
|
||||||
// Load the user the first time.
|
// Load the user the first time.
|
||||||
userService.load();
|
userService.load();
|
||||||
|
|
||||||
|
@ -536,7 +540,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu
|
||||||
|
|
||||||
planService.handleNotedPlan = function() {
|
planService.handleNotedPlan = function() {
|
||||||
var planId = planService.getAndResetNotedPlan();
|
var planId = planService.getAndResetNotedPlan();
|
||||||
if (!planId) { return; }
|
if (!planId) { return false; }
|
||||||
|
|
||||||
UserService.load(function() {
|
UserService.load(function() {
|
||||||
if (UserService.currentUser().anonymous) {
|
if (UserService.currentUser().anonymous) {
|
||||||
|
@ -551,6 +555,8 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
planService.getAndResetNotedPlan = function() {
|
planService.getAndResetNotedPlan = function() {
|
||||||
|
@ -1121,7 +1127,7 @@ quayApp.directive('signinForm', function () {
|
||||||
'signInStarted': '&signInStarted',
|
'signInStarted': '&signInStarted',
|
||||||
'signedIn': '&signedIn'
|
'signedIn': '&signedIn'
|
||||||
},
|
},
|
||||||
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService) {
|
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService, CookieService) {
|
||||||
$scope.showGithub = function() {
|
$scope.showGithub = function() {
|
||||||
$scope.markStarted();
|
$scope.markStarted();
|
||||||
|
|
||||||
|
@ -1130,6 +1136,10 @@ quayApp.directive('signinForm', function () {
|
||||||
$scope.mixpanelDistinctIdClause = "&state=" + encodeURIComponent(mixpanel.get_distinct_id());
|
$scope.mixpanelDistinctIdClause = "&state=" + encodeURIComponent(mixpanel.get_distinct_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save the redirect URL in a cookie so that we can redirect back after GitHub returns to us.
|
||||||
|
var redirectURL = $scope.redirectUrl || window.location.toString();
|
||||||
|
CookieService.putPermanent('quay.redirectAfterLoad', redirectURL);
|
||||||
|
|
||||||
// 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() {
|
||||||
|
@ -1162,7 +1172,7 @@ quayApp.directive('signinForm', function () {
|
||||||
// Note: The timeout of 500ms is needed to ensure dialogs containing sign in
|
// Note: The timeout of 500ms is needed to ensure dialogs containing sign in
|
||||||
// forms get removed before the location changes.
|
// forms get removed before the location changes.
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
if ($scope.redirectUrl == $location.path()) {
|
if (!$scope.redirectUrl || $scope.redirectUrl == $location.path()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$location.path($scope.redirectUrl ? $scope.redirectUrl : '/');
|
$location.path($scope.redirectUrl ? $scope.redirectUrl : '/');
|
||||||
|
@ -3569,8 +3579,8 @@ quayApp.directive('ngVisible', function () {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanService', '$http', '$timeout',
|
quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanService', '$http', '$timeout', 'CookieService',
|
||||||
function($location, $rootScope, Restangular, UserService, PlanService, $http, $timeout) {
|
function($location, $rootScope, Restangular, UserService, PlanService, $http, $timeout, CookieService) {
|
||||||
|
|
||||||
// Handle session security.
|
// Handle session security.
|
||||||
Restangular.setDefaultRequestParams(['post', 'put', 'remove', 'delete'], {'_csrf_token': window.__token || ''});
|
Restangular.setDefaultRequestParams(['post', 'put', 'remove', 'delete'], {'_csrf_token': window.__token || ''});
|
||||||
|
@ -3588,7 +3598,16 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if we need to redirect based on a previously chosen plan.
|
// Check if we need to redirect based on a previously chosen plan.
|
||||||
PlanService.handleNotedPlan();
|
var result = PlanService.handleNotedPlan();
|
||||||
|
|
||||||
|
// Check to see if we need to show a redirection page.
|
||||||
|
var redirectUrl = CookieService.get('quay.redirectAfterLoad');
|
||||||
|
CookieService.clear('quay.redirectAfterLoad');
|
||||||
|
|
||||||
|
if (!result && redirectUrl && redirectUrl.indexOf(window.location.href) == 0) {
|
||||||
|
window.location = redirectUrl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var changeTab = function(activeTab, opt_timeout) {
|
var changeTab = function(activeTab, opt_timeout) {
|
||||||
var checkCount = 0;
|
var checkCount = 0;
|
||||||
|
|
|
@ -5,7 +5,13 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body_content %}
|
{% block body_content %}
|
||||||
<div class="container auth-container">
|
<div class="container" ng-if="user.anonymous">
|
||||||
|
<div class="col-sm-6 col-sm-offset-3">
|
||||||
|
<div class="user-setup"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container auth-container" ng-if="!user.anonymous">
|
||||||
<div class="auth-header">
|
<div class="auth-header">
|
||||||
<img src="//www.gravatar.com/avatar/{{ application.organization.gravatar }}?s=48&d=identicon">
|
<img src="//www.gravatar.com/avatar/{{ application.organization.gravatar }}?s=48&d=identicon">
|
||||||
<h2><a href="{{ application.url }}" target="_blank">{{ application.name }}</a></h2>
|
<h2><a href="{{ application.url }}" target="_blank">{{ application.name }}</a></h2>
|
||||||
|
|
Reference in a new issue