aboutsummaryrefslogtreecommitdiffstats
path: root/workflow-designer-ui/src/main
diff options
context:
space:
mode:
authorMalek <malek.zoabi@amdocs.com>2018-07-29 16:29:35 +0300
committerMalek <malek.zoabi@amdocs.com>2018-07-29 16:30:18 +0300
commit5060e887bd40223ae3e2250a6cd1992025c6cf61 (patch)
treeaf57da27f4a80686b7221c544fecb3d711a6bdcf /workflow-designer-ui/src/main
parent2772584fe277c40825420bcbd65a9f7057649df4 (diff)
Add user_id to BE requests
Issue-ID: SDC-1567 Change-Id: I9cac454b762414e28953dd2045b0a8daa31d67b6 Signed-off-by: Malek <malek.zoabi@amdocs.com>
Diffstat (limited to 'workflow-designer-ui/src/main')
-rw-r--r--workflow-designer-ui/src/main/frontend/src/App.js18
-rw-r--r--workflow-designer-ui/src/main/frontend/src/appConstants.js1
-rw-r--r--workflow-designer-ui/src/main/frontend/src/services/restAPIUtil.js7
-rw-r--r--workflow-designer-ui/src/main/frontend/tools/proxy-server.js23
4 files changed, 30 insertions, 19 deletions
diff --git a/workflow-designer-ui/src/main/frontend/src/App.js b/workflow-designer-ui/src/main/frontend/src/App.js
index 7b46fe48..4b42f6f3 100644
--- a/workflow-designer-ui/src/main/frontend/src/App.js
+++ b/workflow-designer-ui/src/main/frontend/src/App.js
@@ -21,7 +21,8 @@ import { Route } from 'react-router-dom';
import { PluginPubSub } from 'shared/pubsub/plugin-pubsub';
import 'resources/scss/style.scss';
import 'bpmn-js-properties-panel/styles/properties.less';
-import { routes } from './routes';
+import { routes } from 'wfapp/routes';
+import { USER_ID } from 'wfapp/appConstants';
const RouteWithSubRoutes = route => (
<Route
@@ -32,10 +33,19 @@ const RouteWithSubRoutes = route => (
);
class App extends Component {
+ constructor(props) {
+ super(props);
+
+ this.searchParams = new URLSearchParams(location.search);
+
+ if (this.searchParams.get('userId')) {
+ localStorage.setItem(USER_ID, this.searchParams.get('userId'));
+ }
+ }
+
componentDidMount() {
- const searchParams = new URLSearchParams(location.search);
- const eventsClientId = searchParams.get('eventsClientId');
- const parentUrl = searchParams.get('parentUrl');
+ const eventsClientId = this.searchParams.get('eventsClientId');
+ const parentUrl = this.searchParams.get('parentUrl');
if (eventsClientId && parentUrl) {
const client = new PluginPubSub(eventsClientId, parentUrl);
diff --git a/workflow-designer-ui/src/main/frontend/src/appConstants.js b/workflow-designer-ui/src/main/frontend/src/appConstants.js
index b1497a95..710c4d8c 100644
--- a/workflow-designer-ui/src/main/frontend/src/appConstants.js
+++ b/workflow-designer-ui/src/main/frontend/src/appConstants.js
@@ -16,6 +16,7 @@
import { createAction } from 'redux-actions';
export const LANG = 'en';
+export const USER_ID = 'USER_ID';
export const VERSION_LEVEL_LIST = [
{
id: '2',
diff --git a/workflow-designer-ui/src/main/frontend/src/services/restAPIUtil.js b/workflow-designer-ui/src/main/frontend/src/services/restAPIUtil.js
index c0d72c0e..d5c0f9b0 100644
--- a/workflow-designer-ui/src/main/frontend/src/services/restAPIUtil.js
+++ b/workflow-designer-ui/src/main/frontend/src/services/restAPIUtil.js
@@ -18,6 +18,7 @@ import md5 from 'md5';
import axios from 'axios';
import store from 'wfapp/store';
+import { USER_ID } from 'wfapp/appConstants';
import {
sendRequestAction,
@@ -44,7 +45,6 @@ const AUTHORIZATION_HEADER = 'X-AUTH-TOKEN';
const STORAGE_AUTH_KEY = 'sdc-auth-token';
const REQUEST_ID_HEADER = 'X-ECOMP-RequestID';
const CONTENT_MD5_HEADER = 'Content-MD5';
-const USER_ID = 'USER_ID';
function applySecurity(options, data) {
let headers = options.headers || (options.headers = {});
@@ -70,7 +70,10 @@ function applySecurity(options, data) {
md5(JSON.stringify(data)).toLowerCase()
);
}
- headers[USER_ID] = 'cs0008';
+
+ if (localStorage.getItem(USER_ID)) {
+ headers[USER_ID] = localStorage.getItem(USER_ID);
+ }
}
function handleSuccess(responseHeaders, requestHeaders) {
diff --git a/workflow-designer-ui/src/main/frontend/tools/proxy-server.js b/workflow-designer-ui/src/main/frontend/tools/proxy-server.js
index 3193fb16..397b0ba6 100644
--- a/workflow-designer-ui/src/main/frontend/tools/proxy-server.js
+++ b/workflow-designer-ui/src/main/frontend/tools/proxy-server.js
@@ -13,24 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-'use strict';
+'use strict'
-const proxy = require('http-proxy-middleware');
-const devConfig = require('./getDevConfig');
+const proxy = require('http-proxy-middleware')
+const devConfig = require('./getDevConfig')
module.exports = function(server) {
let proxyConfigDefaults = {
changeOrigin: true,
secure: false,
- onProxyRes: (proxyRes, req, res) => {
- let setCookie = proxyRes.headers['set-cookie'];
- if (setCookie) {
- setCookie[0] = setCookie[0].replace('USER_ID', 'cs0008');
- }
+ onProxyReq: (proxyReq, req, res) => {
+ proxyReq.setHeader('USER_ID', devConfig.proxyConfig.cookies.USER_ID)
},
- };
+ }
- let middlewares = [];
+ let middlewares = []
middlewares.push(
proxy(
@@ -39,6 +36,6 @@ module.exports = function(server) {
target: devConfig.proxyTarget,
}),
),
- );
- server.use(middlewares);
-};
+ )
+ server.use(middlewares)
+}