Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error page when routing to settings page without user login #80

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devportal-webapp",
"version": "1.0.68",
"version": "1.0.70",
"description": "devportal-webapp",
"main": "index.js",
"scripts": {
Expand Down
12 changes: 9 additions & 3 deletions src/controllers/settingsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ const loadSettingPage = async (req, res) => {
//retrieve orgID from the user object
if (req.user) {
orgID = req.user[constants.ORG_ID];
} else {
let orgName = req.params.orgName;
orgID = await adminDao.getOrgId(orgName);
const templatePath = path.join(require.main.filename, '..', 'pages', 'error-page', 'page.hbs');
const templateResponse = fs.readFileSync(templatePath, constants.CHARSET_UTF8);
const layoutResponse = await loadLayoutFromAPI(orgID);
let html = await renderGivenTemplate(templateResponse, layoutResponse, {});
return res.send(html);
}

let templateContent = {
Expand All @@ -43,15 +51,14 @@ const loadSettingPage = async (req, res) => {
orgContent: true
}
let layoutResponse = "";
let views;
try {
if (config.mode === constants.DEV_MODE) {
const retrievedIDP = await getMockIdentityProvider();
templateContent.idp = retrievedIDP;
views = [{
'name': 'Default'
}]
}
if (views && views.length > 0) {
templateContent.content = true;
templateContent.orgContent = false;
templateContent.views = views;
Expand All @@ -64,7 +71,6 @@ const loadSettingPage = async (req, res) => {
}
//TODO: fetch view names from DB
const file = await adminService.getOrgContent(orgID, 'layout', 'main.hbs', 'layout');
let views;
if (file !== null) {
views = [{
'name': 'Default'
Expand Down