aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FileRouter.ts1
-rw-r--r--src/app.ts9
-rw-r--r--src/auth.ts16
3 files changed, 11 insertions, 15 deletions
diff --git a/src/FileRouter.ts b/src/FileRouter.ts
index 1cef85d..4dc3105 100644
--- a/src/FileRouter.ts
+++ b/src/FileRouter.ts
@@ -447,7 +447,6 @@ const postProjectName: Middleware =
});
promise = file.save();
project = new Project({
- uuid: uuid.generate(),
name: req.params.project_name,
rootFolder: file
});
diff --git a/src/app.ts b/src/app.ts
index bedffa4..897896a 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -94,8 +94,7 @@ class App {
}
});
if (user === null) {
- next(new RequestError(404, 'user_not_found'));
- return;
+ return next(new RequestError(404, 'user_not_found'));
} else {
res.locals.user = user;
}
@@ -142,8 +141,7 @@ class App {
}
});
if (fileOrNull === null) {
- next();
- return;
+ return next();
} else {
file = fileOrNull;
}
@@ -159,8 +157,7 @@ class App {
}
});
if (parentFolder === null) {
- next();
- return;
+ return next();
}
res.locals.parentFolder = parentFolder;
const tFile: File | undefined = parentFolder.containedFiles.find(
diff --git a/src/auth.ts b/src/auth.ts
index 6339260..b055d9f 100644
--- a/src/auth.ts
+++ b/src/auth.ts
@@ -26,7 +26,7 @@ export class AuthRouter {
username: req.body.username
},
include: [ UserGroup, Project]
- });
+ });
if (user === null) {
// Whoa, what an error!
@@ -68,18 +68,18 @@ export class AuthRouter {
// Checks for errors within request before authentication
public checkErr(req: Request, res: Response, next: NextFunction): void {
if (!req.body.grant_type || !req.body.username || !req.body.password) {
- next(new RequestError(400, 'invalid_request', 'Missing parameters'));
+ return next(new RequestError(400, 'invalid_request', 'Missing parameters'));
}
if (req.body.grant_type !== 'refresh_token'
&& req.body.grant_type !== 'password') {
- next(new RequestError(400, 'unsupported_grant_type', 'invalid grant type'));
+ return next(new RequestError(400, 'unsupported_grant_type', `invalid grant type`));
}
next();
}
-
+
// Configure local strategy to use with passport-js.
private configStrategy(): void {
// tslint:disable-next-line:typedef
@@ -93,7 +93,7 @@ export class AuthRouter {
if (!user || user.password !== password) {
return done(null, false);
- }
+ }
return done(null, user);
}));
}
@@ -122,10 +122,10 @@ export const unauthorisedErr: Errorware =
};
// Middleware to check privileges - admin
-export const isAdmin: any =
-(req: Request, res: Response, next: NextFunction): void => {
+export const isAdmin: any =
+(req: Request, res: Response, next: NextFunction): void => {
var isAdmin: boolean = req.user.object.userGroups.some((x: UserGroup): boolean => x.name === 'admin');
-
+
if (!isAdmin) {
next(new RequestError(
401, 'not_authorised',