Skip to content

Commit

Permalink
re-apply ClaraKM SSO customization
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshMcCullough authored and OGRoomService committed Sep 27, 2024
1 parent bba95d2 commit d932671
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"jquery": "^3.7.1",
"jquery-file-download": "1.4.6",
"jquery-minicolors": "2.1.10",
"js-cookie": "^2.2.0",
"leaflet": "1.7.1",
"leaflet-editable": "1.2.0",
"leaflet-groupedlayercontrol": "git+https://github.com/newmanw/leaflet-groupedlayercontrol.git#master",
Expand Down
18 changes: 16 additions & 2 deletions web-app/src/ng1/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import fileBrowser from './file-upload/file.browser.component';
import uiRouter from "@uirouter/angularjs";
import { SwaggerComponent } from "../app/swagger/swagger.component";
import { downgradeComponent, downgradeInjectable } from '@angular/upgrade/static';
import cookies from 'js-cookie';

import {
MatIcon,
Expand Down Expand Up @@ -475,9 +476,9 @@ function config($httpProvider, $locationProvider, $stateProvider, $urlRouterProv
});
}

run.$inject = ['$rootScope', '$uibModal', '$state', 'Api'];
run.$inject = ['$rootScope', '$uibModal', '$state', 'Api', 'LocalStorageService', 'UserService'];

function run($rootScope, $uibModal, $state, Api) {
function run($rootScope, $uibModal, $state, Api, LocalStorageService, UserService) {

$rootScope.$on('event:auth-loginRequired', function(e, response) {
const stateExceptions = ['landing'];
Expand Down Expand Up @@ -519,6 +520,19 @@ function run($rootScope, $uibModal, $state, Api) {
});
}
});

trySSO(LocalStorageService, UserService);
}

function trySSO(LocalStorageService, UserService) {
const ssoTokenCookie = cookies.get('mage-sso-token');

// if SSO token exists, set it in local storage and fetch current user
if (ssoTokenCookie) {
LocalStorageService.setToken(ssoTokenCookie);

return UserService.getMyself();
}
}

export default app;

0 comments on commit d932671

Please sign in to comment.