Merge branch 'develop' of Software_Engineering_I/greenvironment-server into master

pull/5/head
Trivernis 5 years ago committed by Gitea
commit 79f099471c

@ -63,6 +63,7 @@ export class UploadRoute extends Route {
// Uploads a file to the data directory and returns the filename
this.router.use(async (req, res) => {
let uploadConfirmation: IUploadConfirmation;
try {
if (req.session.userId) {
if (req.files.profilePicture) {
uploadConfirmation = await this.uploadProfilePicture(req);
@ -84,7 +85,13 @@ export class UploadRoute extends Route {
success: false,
};
}
if (uploadConfirmation.error) {
} catch (err) {
uploadConfirmation = {
error: err,
success: false,
};
}
if (uploadConfirmation?.error) {
res.status(httpStatus.BAD_REQUEST);
}
res.json(uploadConfirmation);

Loading…
Cancel
Save