diff options
author | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-07-30 07:15:30 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-07-30 07:15:30 +0000 |
commit | 4930e7f2f401f320bf4f017ba4daaae9b5c10c9f (patch) | |
tree | 402870bccb425ef2b468632f4a73dc5bec708af8 | |
parent | 67c6330e4fab794fc065fa667f39693a303dd2aa (diff) | |
parent | 5060e887bd40223ae3e2250a6cd1992025c6cf61 (diff) |
Merge "Add user_id to BE requests"
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) +} |