Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Fix https error
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreburgy committed Dec 15, 2015
1 parent f8d9b4f commit 26626fb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
13 changes: 4 additions & 9 deletions files/api/admin/public/src/app.run.js
Expand Up @@ -19,8 +19,7 @@
'Config',
'initService',
'userService',
'layoutService',
'$location'];
'layoutService'];

function run($rootScope,
$state,
Expand All @@ -34,8 +33,7 @@
Config,
initService,
userService,
layoutService,
$location) {
layoutService) {

// Set global variable
$rootScope.auth = authService;
Expand All @@ -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
Expand Down
Expand Up @@ -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.');
});

Expand Down
Expand Up @@ -9,7 +9,7 @@
*/
angular.module('frontend')
.constant('Config', {
backendUrl: window.backendUrl,
backendUrl: window.backendUrl || window.location.origin,
frontendUrl: window.frontendUrl
});
})();
16 changes: 2 additions & 14 deletions files/api/admin/public/src/core/services/configService.service.js
Expand Up @@ -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;

Expand Down

0 comments on commit 26626fb

Please sign in to comment.