Comparing version 0.0.31 to 0.0.32
const environment = exports.environment = process.env.NODE_ENV; | ||
const defautlGoogleAnalytics = 'UA-99304839-1'; | ||
const defautlGoogleAnalytics = exports.defautlGoogleAnalytics = 'UA-99304839-1'; | ||
@@ -8,9 +8,12 @@ switch (environment) { | ||
exports.apiUrl = 'http://localhost:3501/'; | ||
exports.portalUrl = 'http://localhost:3506/'; | ||
break; | ||
case 'staging': | ||
exports.apiUrl = 'http://test.api.aha.volenday.com/'; | ||
exports.portalUrl = 'http://test.portal.aha.volenday.com/'; | ||
break; | ||
case 'development': | ||
exports.apiUrl = 'https://api-black.aha.volenday.com/'; | ||
exports.apiUrl = process.env.API_URL; | ||
exports.portalUrl = process.env.PORTAL_URL; | ||
break; | ||
} |
{ | ||
"name": "volenday", | ||
"version": "0.0.31", | ||
"version": "0.0.32", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "license": "UNLICENSED", |
@@ -6,5 +6,8 @@ const createError = require('http-errors'); | ||
const GoogleAnalytics = require('./GoogleAnalytics'); | ||
const { apiUrl } = require('../../config'); | ||
const { apiUrl, portalUrl } = require('../../config'); | ||
module.exports = () => { | ||
module.exports = (params = {}) => { | ||
params = { ...params } | ||
params.Type = params.Type || 'portal' | ||
return async (req, res, next) => { | ||
@@ -35,37 +38,53 @@ let currentHostName = req.get('x-forwarded-host') || req.get('host'); | ||
let configurations = keyBy(application.Configurations, 'Key'), | ||
ico = '', googleAnalytics = await GoogleAnalytics(), portalAuthentication = {}; | ||
ico = '', googleAnalytics = await GoogleAnalytics(), portalAuthentication = {}, newPortalUrl = portalUrl; | ||
req.session.portalUrl = `${appUrl}client/${application.Id}`; | ||
if (params.Type == 'portal') { | ||
req.session.portalUrl = `${appUrl}client/${application.Id}`; | ||
} else { | ||
req.session.logOutUrl = `${newPortalUrl}logout/${application.Id}?${param({ redirect: `${appUrl}callback` })}`; | ||
req.session.portalUrl = `${newPortalUrl}client/${application.Id}?${param({ redirect: `${appUrl}callback` })}`; | ||
} | ||
if (configurations['Portal Host Names']) { | ||
if (configurations['Portal Host Names'].Value.length) { | ||
let portalUrlTemp = configurations['Portal Host Names'].Value[0]; | ||
appUrl = `${portalUrlTemp.SSLStatus ? 'https' : 'http'}://${portalUrlTemp.HostName}/`; | ||
req.session.portalUrl = appUrl; | ||
if (params.Type == 'portal') { | ||
appUrl = `${portalUrlTemp.SSLStatus ? 'https' : 'http'}://${portalUrlTemp.HostName}/`; | ||
req.session.portalUrl = appUrl; | ||
} else { | ||
newPortalUrl = `${portalUrlTemp.SSLStatus ? 'https' : 'http'}://${portalUrlTemp.HostName}/`; | ||
req.session.logOutUrl = `${newPortalUrl}/logout/${application.Id}?${param({ redirect: `${appUrl}callback` })}`; | ||
req.session.portalUrl = `${newPortalUrl}?${param({ redirect: `${appUrl}callback` })}`; | ||
} | ||
} | ||
} | ||
if (configurations['Portal Authentication']) { | ||
portalAuthentication = configurations['Portal Authentication'].Value | ||
} else { | ||
portalAuthentication = { Email: true, Mobile: true } | ||
} | ||
if (params.Type == 'portal') { | ||
if (configurations['Portal Authentication']) { | ||
portalAuthentication = configurations['Portal Authentication'].Value | ||
} else { | ||
portalAuthentication = { Email: true, Mobile: true } | ||
} | ||
if (configurations['ICO']) { | ||
ico = configurations['ICO'].Value | ||
} | ||
if (configurations['ICO']) { | ||
ico = configurations['ICO'].Value | ||
} | ||
if (configurations['Google Analytics']) { | ||
googleAnalytics = await GoogleAnalytics(configurations['Google Analytics'].Value); | ||
} | ||
if (configurations['Google Analytics']) { | ||
googleAnalytics = await GoogleAnalytics(configurations['Google Analytics'].Value); | ||
} | ||
req.data = { | ||
application, | ||
appUrl, | ||
googleAnalytics, | ||
ico, | ||
portalAuthentication | ||
req.data = { | ||
application, | ||
appUrl, | ||
googleAnalytics, | ||
ico, | ||
portalAuthentication | ||
} | ||
next(); | ||
} else { | ||
res.redirect(req.session.portalUrl); | ||
} | ||
next(); | ||
} | ||
} |
@@ -6,5 +6,9 @@ const createError = require('http-errors'); | ||
const GoogleAnalytics = require('./GoogleAnalytics'); | ||
const { apiUrl } = require('../../config'); | ||
const { apiUrl, portalUrl } = require('../../config'); | ||
module.exports = () => { | ||
module.exports = (params = {}) => { | ||
params = { ...params } | ||
params.Type = params.Type || 'portal' | ||
params.HostNameKey = params.HostNameKey || 'Portal Host Names' | ||
return async (req, res, next) => { | ||
@@ -19,3 +23,3 @@ let currentHostName = req.get('x-forwarded-host') || req.get('host'); | ||
$elemMatch: { | ||
Key: 'Portal Host Names', | ||
Key: params.HostNameKey, | ||
Value: { | ||
@@ -51,37 +55,53 @@ $elemMatch: { | ||
let configurations = keyBy(application.Configurations, 'Key'), | ||
ico = '', googleAnalytics = await GoogleAnalytics(), portalAuthentication = {}; | ||
ico = '', googleAnalytics = await GoogleAnalytics(), portalAuthentication = {}, newPortalUrl = portalUrl; | ||
req.session.portalUrl = `${appUrl}client/${application.Id}`; | ||
if (params.Type == 'portal') { | ||
req.session.portalUrl = `${appUrl}client/${application.Id}`; | ||
} else { | ||
req.session.logOutUrl = `${newPortalUrl}logout/${application.Id}?${param({ redirect: `${appUrl}callback` })}`; | ||
req.session.portalUrl = `${newPortalUrl}client/${application.Id}?${param({ redirect: `${appUrl}callback` })}`; | ||
} | ||
if (configurations['Portal Host Names']) { | ||
if (configurations['Portal Host Names'].Value.length) { | ||
let portalUrlTemp = configurations['Portal Host Names'].Value[0]; | ||
appUrl = `${portalUrlTemp.SSLStatus ? 'https' : 'http'}://${portalUrlTemp.HostName}/`; | ||
req.session.portalUrl = appUrl; | ||
if (params.Type == 'portal') { | ||
appUrl = `${portalUrlTemp.SSLStatus ? 'https' : 'http'}://${portalUrlTemp.HostName}/`; | ||
req.session.portalUrl = appUrl; | ||
} else { | ||
newPortalUrl = `${portalUrlTemp.SSLStatus ? 'https' : 'http'}://${portalUrlTemp.HostName}/`; | ||
req.session.logOutUrl = `${newPortalUrl}/logout/${application.Id}?${param({ redirect: `${appUrl}callback` })}`; | ||
req.session.portalUrl = `${newPortalUrl}?${param({ redirect: `${appUrl}callback` })}`; | ||
} | ||
} | ||
} | ||
if (configurations['Portal Authentication']) { | ||
portalAuthentication = configurations['Portal Authentication'].Value | ||
} else { | ||
portalAuthentication = { Email: true, Mobile: true } | ||
} | ||
if (params.Type == 'portal') { | ||
if (configurations['Portal Authentication']) { | ||
portalAuthentication = configurations['Portal Authentication'].Value | ||
} else { | ||
portalAuthentication = { Email: true, Mobile: true } | ||
} | ||
if (configurations['ICO']) { | ||
ico = configurations['ICO'].Value | ||
} | ||
if (configurations['ICO']) { | ||
ico = configurations['ICO'].Value | ||
} | ||
if (configurations['Google Analytics']) { | ||
googleAnalytics = await GoogleAnalytics(configurations['Google Analytics'].Value); | ||
} | ||
if (configurations['Google Analytics']) { | ||
googleAnalytics = await GoogleAnalytics(configurations['Google Analytics'].Value); | ||
} | ||
req.data = { | ||
application, | ||
appUrl, | ||
googleAnalytics, | ||
ico, | ||
portalAuthentication | ||
req.data = { | ||
application, | ||
appUrl, | ||
googleAnalytics, | ||
ico, | ||
portalAuthentication | ||
} | ||
next(); | ||
} else { | ||
res.redirect(req.session.portalUrl); | ||
} | ||
next(); | ||
} | ||
} |
@@ -48,2 +48,3 @@ const { keyBy } = require('lodash'); | ||
portalAuthentication, | ||
portalUrl, | ||
token, | ||
@@ -50,0 +51,0 @@ user |
296865
1491