From 26626fb8be564b460b147a7d57f93449760f33f6 Mon Sep 17 00:00:00 2001 From: Pierre BURGY Date: Tue, 15 Dec 2015 13:15:47 +0100 Subject: [PATCH] Fix https error --- files/api/admin/public/src/app.run.js | 13 ++++--------- .../src/core/auth/services/auth.service.js | 2 +- .../public/src/core/constants/Config.constant.js | 2 +- .../src/core/services/configService.service.js | 16 ++-------------- 4 files changed, 8 insertions(+), 25 deletions(-) diff --git a/files/api/admin/public/src/app.run.js b/files/api/admin/public/src/app.run.js index 8cb6332..398f5f5 100755 --- a/files/api/admin/public/src/app.run.js +++ b/files/api/admin/public/src/app.run.js @@ -19,8 +19,7 @@ 'Config', 'initService', 'userService', - 'layoutService', - '$location']; + 'layoutService']; function run($rootScope, $state, @@ -34,8 +33,7 @@ Config, initService, userService, - layoutService, - $location) { + layoutService) { // Set global variable $rootScope.auth = authService; @@ -47,15 +45,12 @@ $rootScope.user = userService.user; $rootScope._ = _; - // Get app config from app url (eg. http://localhost:1337). - configService.getApp($location.search().url) + // Get app config. + configService.getApp() .then(function () { initService.deferred.resolve(); }); - // Remove `appUrl` parameter. - $location.search('appUrl', undefined); - /** * Route state change start event, this is needed for following: * 1) Check if user is authenticated to access page, and if not redirect user back to login page diff --git a/files/api/admin/public/src/core/auth/services/auth.service.js b/files/api/admin/public/src/core/auth/services/auth.service.js index fed372d..24021d6 100755 --- a/files/api/admin/public/src/core/auth/services/auth.service.js +++ b/files/api/admin/public/src/core/auth/services/auth.service.js @@ -65,7 +65,7 @@ }) .then(function (response) { var configService = $injector.get('configService'); - configService.getApp(undefined, true).then(function () { + configService.getApp(true).then(function () { messageService.success('You have been logged in.'); }); diff --git a/files/api/admin/public/src/core/constants/Config.constant.js b/files/api/admin/public/src/core/constants/Config.constant.js index 2998d3f..f51aaef 100755 --- a/files/api/admin/public/src/core/constants/Config.constant.js +++ b/files/api/admin/public/src/core/constants/Config.constant.js @@ -9,7 +9,7 @@ */ angular.module('frontend') .constant('Config', { - backendUrl: window.backendUrl, + backendUrl: window.backendUrl || window.location.origin, frontendUrl: window.frontendUrl }); })(); diff --git a/files/api/admin/public/src/core/services/configService.service.js b/files/api/admin/public/src/core/services/configService.service.js index 644571e..658e429 100755 --- a/files/api/admin/public/src/core/services/configService.service.js +++ b/files/api/admin/public/src/core/services/configService.service.js @@ -29,34 +29,22 @@ /** * Gey the config of the app from its API. * - * @param {String} appUrl * @param {Boolean} ignoreError * @returns {*} */ - function getApp(appUrl, ignoreError) { + function getApp(ignoreError) { // Init promise. var deferred = $q.defer(); - // Set the appUrl in the local storage. - $sessionStorage.appUrl = appUrl ? appUrl : $sessionStorage.appUrl; - appUrl = $sessionStorage.appUrl; - - // Set the default appUrl. - appUrl = appUrl ? appUrl : Config.backendUrl; - $sessionStorage.appUrl = appUrl; - // Get the config of the app. $http({ method: 'GET', - url: appUrl + '/admin/config' + url: Config.backendUrl + '/admin/config' }).then(function (response) { // Set the config. config = response.data; - // Set the backend url in Config object. - Config.backendUrl = response.data.settings && response.data.settings.url || Config.backendUrl; - // Set the isNewApp value in configService object. config.isNewApp = response.data.settings && response.data.settings.isNewApp;