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

Reference pull request for full details. #68

Merged
merged 1 commit into from
May 24, 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
10 changes: 8 additions & 2 deletions Database/POAM_Tracking_Tool_Data_Model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
!########################################################################
*/

CREATE TABLE `cpat`.`config` (
`key` VARCHAR(45) NOT NULL,
`value` VARCHAR(255) NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE `cpat`.`user` (
`userId` int NOT NULL AUTO_INCREMENT,
Expand All @@ -18,10 +23,11 @@ CREATE TABLE `cpat`.`user` (
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastAccess` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastCollectionAccessedId` int NOT NULL DEFAULT '0',
`accountStatus` varchar(25) NOT NULL DEFAULT 'Pending',
`officeOrg` varchar(100) NOT NULL,
`accountStatus` varchar(25) NOT NULL DEFAULT 'PENDING',
`officeOrg` VARCHAR(100) NULL DEFAULT 'UNKNOWN',
`fullName` varchar(100) DEFAULT NULL,
`defaultTheme` varchar(20) DEFAULT 'dark',
`lastClaims` json DEFAULT ('{}'),
`isAdmin` int NOT NULL DEFAULT '0',
PRIMARY KEY (`userId`),
UNIQUE KEY `email_UNIQUE` (`email`) USING BTREE,
Expand Down
4 changes: 3 additions & 1 deletion api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ CPAT_API_AUTHORITY="http://localhost:2020/realms/RMFTools"
CPAT_JWT_SCOPE_CLAIM="c-pat:read c-pat:op openid profile email"
CPAT_JWT_USERNAME_CLAIM="preferred_username"
CPAT_JWT_SERVICENAME_CLAIM="clientId"
CPAT_JWT_NAME_CLAIM="name"
CPAT_JWT_FIRST_NAME_CLAIM="given_name"
CPAT_JWT_LAST_NAME_CLAIM="family_name"
CPAT_JWT_FULL_NAME_CLAIM="name"
CPAT_JWT_PRIVILEGES_CLAIM="realm_access.roles"
CPAT_JWT_EMAIL_CLAIM="email"

Expand Down
25 changes: 0 additions & 25 deletions api/Controllers/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,6 @@

const collectionService = require('../Services/mysql/collectionService');

module.exports.getCollectionPermissions = async function getCollectionPermissions(req, res, next) {
try {
const permissions = await collectionService.getCollectionPermissions(req, res, next);
res.status(200).json(permissions);
} catch (error) {
if (error.message === 'collectionId is required') {
res.status(400).json({ error: 'Validation Error', detail: 'collectionId is required' });
} else {
res.status(500).json({ error: 'Internal Server Error', detail: error.message });
}
}
};

module.exports.getCollection = async function getCollection(req, res, next) {
try {
const getCollection = await collectionService.getCollection(req.params.userName, req.params.collectionId, req, res, next);
if (getCollection) {
res.status(200).json(getCollection);
} else {
res.status(204).send();
}
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', detail: error.message });
}
};

module.exports.getCollectionBasicList = async function getCollectionBasicList(req, res, next) {
try {
Expand Down
53 changes: 53 additions & 0 deletions api/Controllers/Operation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
!#######################################################################
! C-PATTM SOFTWARE
! CRANE C-PATTM plan of action and milestones software. Use is governed by the Open Source Academic Research License Agreement contained in the file
! crane_C_PAT.1_license.txt, which is part of this software package. BY
! USING OR MODIFYING THIS SOFTWARE, YOU ARE AGREEING TO THE TERMS AND
! CONDITIONS OF THE LICENSE.
!########################################################################
*/

const operationService = require('../Services/mysql/operationService');
const config = require('../utils/config');
module.exports.getConfiguration = async function getConfiguration(req, res, next) {
try {
let dbConfigs = await operationService.getConfiguration()
let version = { version: config.version }
let response = { ...version, ...dbConfigs }
res.json(response)
}
catch (err) {
next(err);
}
}

module.exports.setConfigurationItem = async function setConfigurationItem(req, res, next) {
try {
const { key, value } = req.body;
if (!key || !value) {
return res.status(400).json({ error: 'Key and value are required.' });
}

await operationService.setConfigurationItem(key, value);
res.json({ message: 'Configuration item updated successfully.' });

} catch (err) {
next(err);
}
};

module.exports.deleteConfigurationItem = async function deleteConfigurationItem(req, res, next) {
try {
const { key } = req.params;

if (!key) {
return res.status(400).json({ error: 'Key is required.' });
}

await operationService.deleteConfigurationItem(key);
res.json({ message: 'Configuration item deleted successfully.' });
} catch (err) {
next(err);
}
};
26 changes: 26 additions & 0 deletions api/Controllers/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@

const permissionService = require('../Services/mysql/permissionsService');

module.exports.getCollectionPermission = async function getCollectionPermission(req, res, next) {
try {
const getCollection = await permissionService.getCollectionPermission(req.params.userName, req.params.collectionId, req, res, next);
if (getCollection) {
res.status(200).json(getCollection);
} else {
res.status(204).send();
}
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', detail: error.message });
}
};

module.exports.getCollectionPermissions = async function getCollectionPermissions(req, res, next) {
try {
const permissions = await permissionService.getCollectionPermissions(req, res, next);
res.status(200).json(permissions);
} catch (error) {
if (error.message === 'collectionId is required') {
res.status(400).json({ error: 'Validation Error', detail: 'collectionId is required' });
} else {
res.status(500).json({ error: 'Internal Server Error', detail: error.message });
}
}
};

module.exports.postPermission = async function postPermission(req, res, next) {
try {
const permission = await permissionService.postPermission(req, res, next);
Expand Down
4 changes: 2 additions & 2 deletions api/Controllers/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ module.exports.deleteUser = async function deleteUser(req, res, next) {
}
};

module.exports.loginout = async function loginout(req, res, next) {
module.exports.loginState = async function loginState(req, res, next) {
try {
const message = await userService.loginout(req, res, next);
const message = await userService.loginState(req, res, next);
res.status(201).json(message);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', detail: error.message });
Expand Down
48 changes: 0 additions & 48 deletions api/Controllers/auth.js

This file was deleted.

165 changes: 0 additions & 165 deletions api/Services/mysql/authService.js

This file was deleted.

Loading
Loading