fix(app): rewrite URLHelper to avoid an issue with minification

pull/2749/head
Anthony Lapenna 2019-02-18 15:08:54 +13:00
parent 7643f8d08c
commit 2ef8c0b33e
2 changed files with 14 additions and 8 deletions

View File

@ -1,6 +1,10 @@
angular.module('portainer.app').service('urlHelper', function urlHelper($window) { angular.module('portainer.app')
this.getParameter = getParameter; .factory('URLHelper', ['$window', function URLHelperFactory($window) {
this.cleanParameters = cleanParameters; 'use strict';
var helper = {};
helper.getParameter = getParameter;
helper.cleanParameters = cleanParameters;
function getParameter(param) { function getParameter(param) {
var parameters = extractParameters(); var parameters = extractParameters();
@ -21,4 +25,6 @@ angular.module('portainer.app').service('urlHelper', function urlHelper($window)
function cleanParameters() { function cleanParameters() {
$window.location.search = ''; $window.location.search = '';
} }
});
return helper;
}]);

View File

@ -1,5 +1,5 @@
angular.module('portainer.app').controller('AuthenticationController', ['$q', '$scope', '$state', '$stateParams', '$sanitize', 'Authentication', 'UserService', 'EndpointService', 'StateManager', 'Notifications', 'SettingsService', 'urlHelper', angular.module('portainer.app').controller('AuthenticationController', ['$q', '$scope', '$state', '$stateParams', '$sanitize', 'Authentication', 'UserService', 'EndpointService', 'StateManager', 'Notifications', 'SettingsService', 'URLHelper',
function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserService, EndpointService, StateManager, Notifications, SettingsService, urlHelper) { function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserService, EndpointService, StateManager, Notifications, SettingsService, URLHelper) {
$scope.logo = StateManager.getState().application.logo; $scope.logo = StateManager.getState().application.logo;
$scope.formValues = { $scope.formValues = {
@ -105,7 +105,7 @@ angular.module('portainer.app').controller('AuthenticationController', ['$q', '$
authenticatedFlow(); authenticatedFlow();
} }
var code = urlHelper.getParameter('code'); var code = URLHelper.getParameter('code');
if (code) { if (code) {
oAuthLogin(code); oAuthLogin(code);
} else { } else {
@ -116,7 +116,7 @@ angular.module('portainer.app').controller('AuthenticationController', ['$q', '$
function oAuthLogin(code) { function oAuthLogin(code) {
return Authentication.OAuthLogin(code) return Authentication.OAuthLogin(code)
.then(function success() { .then(function success() {
urlHelper.cleanParameters(); URLHelper.cleanParameters();
$state.go('portainer.home'); $state.go('portainer.home');
}) })
.catch(function error() { .catch(function error() {