aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ecosystem.config.js1
-rw-r--r--package.json1
-rw-r--r--src/FileRouter.ts22
-rw-r--r--src/errors/errorware.ts3
-rw-r--r--src/files.ts2
-rw-r--r--src/index.ts6
6 files changed, 18 insertions, 17 deletions
diff --git a/ecosystem.config.js b/ecosystem.config.js
index 5fe5685..9510731 100644
--- a/ecosystem.config.js
+++ b/ecosystem.config.js
@@ -7,7 +7,6 @@ module.exports = {
{
name: 'JHBE4',
script: 'src/index.ts',
- // cwd: '.',
args: '',
instances: 4,
watch: false,
diff --git a/package.json b/package.json
index 6475d72..560dd1d 100644
--- a/package.json
+++ b/package.json
@@ -19,6 +19,7 @@
"lint": "yarn _lint --fix --force './src/**/*.ts'",
"lint:tests": "yarn _lint --fix --force './test/**/*.ts'",
"start": "pm2 restart ecosystem.config.js",
+ "reload": "pm2 reload ecosystem.config.js",
"stop": "pm2 stop all",
"console": "pm2 monit"
},
diff --git a/src/FileRouter.ts b/src/FileRouter.ts
index dbd556f..35d3977 100644
--- a/src/FileRouter.ts
+++ b/src/FileRouter.ts
@@ -374,8 +374,8 @@ const postUsername: Middleware = async(
let user: User | null | undefined = res.locals.user;
res.locals.modified = true;
- if( req.query.action === 'update'){
- if (user!= null){
+ if(req.query.action === 'update') {
+ if (user != null) {
logger.debug('Editing user');
if(req.body.password != null){
@@ -394,18 +394,16 @@ const postUsername: Middleware = async(
})
await user.$set('userGroups', priv);
}
- }
- else{
+ } else {
next(new RequestError(404, 'user_not_found'));
return;
}
}
else if( req.query.action === 'delete'){
logger.debug('Deleting a user');
- if (user!= null){
+ if (user!= null) {
await user.destroy();
- }
- else{
+ } else {
next(new RequestError(404, 'user_not_found'));
return;
}
@@ -556,11 +554,12 @@ const postProjectName: Middleware = async(
if (project != null) {
project.destroy();
} else {
- next(new RequestError(400, 'project_not_found'));
+ next(new RequestError(404, 'project_not_found'));
}
} else if (req.query.action === 'update_grant') {
+ logger.debug('Project grant update requested');
if (project == null) {
- next(new RequestError(400, 'project_not_found'));
+ next(new RequestError(404, 'project_not_found'));
} else {
const ujp: UserJoinsProject | null = await UserJoinsProject.findOne({
include: [{all: true}],
@@ -570,9 +569,11 @@ const postProjectName: Middleware = async(
}
});
if (ujp != null) {
+ logger.debug(`Removing ${req.body.username}'s old privileges in ${project.name}`);
await ujp.destroy();
}
if (req.body.access_level !== 'none') {
+ logger.debug(`Adding ${req.body.access_level} privileges for ${req.body.username} in ${project.name}`);
try {
let ujp: UserJoinsProject = new UserJoinsProject({
username: req.body.username,
@@ -581,9 +582,10 @@ const postProjectName: Middleware = async(
});
await ujp.save();
} catch (err) {
- next(new RequestError(400, 'invalid_access_level'));
+ next(new RequestError(400, 'invalid_project_privilege'));
}
}
+ logger.debug('Privileges updated');
}
} else {
if (project == null) {
diff --git a/src/errors/errorware.ts b/src/errors/errorware.ts
index e2b5610..8de794d 100644
--- a/src/errors/errorware.ts
+++ b/src/errors/errorware.ts
@@ -117,11 +117,12 @@ export type Errorware =
export const errorHandler: Errorware = (
err: Error, req: Request, res: Response, next: NextFunction
): void => {
- logger.failure(`Responded to ${req.ip}`);
if (RequestError.is(err)) {
+ logger.failure(`Responded to ${req.ip}`);
res.status(err.code)
.json(err.responseBlock());
} else {
+ logger.error(`Uncaught error: ${err}`);
res.status(500).send(err.stack);
}
};
diff --git a/src/files.ts b/src/files.ts
index fe92e3e..6167bd4 100644
--- a/src/files.ts
+++ b/src/files.ts
@@ -142,7 +142,6 @@ export const saveFile: (data: Buffer, projectName: string,
const fd: number = await fs.open(path(fileId, projectName), 'r+');
// Write data to file
fs.write(fd, data, 0, data.length, Number(fuckingOffset), (err: any, bytesWritten: number, buffer: Buffer) => {
- console.log("written: " + bytesWritten)
if (err) {
logger.failure("Error while writing to file: " + err);
}
@@ -184,7 +183,6 @@ export const copyFile: (projName: string, fromId: string, toId: string, move?: b
if (!!move) {
await fs.remove(fromPathFull);
}
- console.log(`copy success of file from \'${fromPathFull}\' to \'${toPathFull}\'`);
}).on('error', (err: any) => {
logger.error(`Error while copying file: ${err}`);
});
diff --git a/src/index.ts b/src/index.ts
index 30f82bf..4120fef 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -108,7 +108,7 @@ async function reset(): Promise<void> {
});
const standardProjectUser: ContributorGroup = new ContributorGroup({
- name: 'standardProjectUser',
+ name: 'regular',
canCreateFiles: true,
canViewFiles: true,
isInternal: false,
@@ -116,14 +116,14 @@ async function reset(): Promise<void> {
});
const readOnlyProjectUser: ContributorGroup = new ContributorGroup({
- name: 'readOnlyProjectUser',
+ name: 'spectator',
canViewFiles: true,
isInternal: false,
description: 'Allows viewing of files in a project '
});
const projectUserManagement: ContributorGroup = new ContributorGroup({
- name: 'projectUserManagement',
+ name: 'project_admin',
canAddUsers: true,
canEditUserPermissions: true,
canRemoveUsers: true,