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) {
this.getParameter = getParameter;
this.cleanParameters = cleanParameters;
angular.module('portainer.app')
.factory('URLHelper', ['$window', function URLHelperFactory($window) {
'use strict';
var helper = {};
helper.getParameter = getParameter;
helper.cleanParameters = cleanParameters;
function getParameter(param) {
var parameters = extractParameters();
@ -21,4 +25,6 @@ angular.module('portainer.app').service('urlHelper', function urlHelper($window)
function cleanParameters() {
$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',
function($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) {
$scope.logo = StateManager.getState().application.logo;
$scope.formValues = {
@ -105,7 +105,7 @@ angular.module('portainer.app').controller('AuthenticationController', ['$q', '$
authenticatedFlow();
}
var code = urlHelper.getParameter('code');
var code = URLHelper.getParameter('code');
if (code) {
oAuthLogin(code);
} else {
@ -116,7 +116,7 @@ angular.module('portainer.app').controller('AuthenticationController', ['$q', '$
function oAuthLogin(code) {
return Authentication.OAuthLogin(code)
.then(function success() {
urlHelper.cleanParameters();
URLHelper.cleanParameters();
$state.go('portainer.home');
})
.catch(function error() {