Skip to content

Commit

Permalink
Update member.controller.ts
Browse files Browse the repository at this point in the history
Added more error-checking to the function for updating the storage unit name.
  • Loading branch information
SalleeMatthew authored and dburleson committed Jul 14, 2024
1 parent 19dd214 commit f4e9f38
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions api/src/controllers/member.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ class MemberController {
if(!session) return;
try {
const storage = await this.memberService.getStorageById(parseInt(request.body.id));
if(!storage){
throw new Error('Storage area not found!');
}
if(storage && storage.member_id !== session.id){
throw new Error('You do not own this storage area');
}
Expand All @@ -401,12 +404,14 @@ class MemberController {
if(storageName.match(bannedwords)){
throw new Error('You can not use this language on CTR!');
}
this.placeService.updatePlaces(
parseInt(request.body.id.toString()),
request.body.column.toString(),
storageName,
);
response.status(200).json({status: 'success'});
if(storage && storage.member_id === session.id){
this.placeService.updatePlaces(
parseInt(request.body.id.toString()),
'name',
storageName,
);
response.status(200).json({status: 'success'});
}
} catch (error) {
console.log(error);
response.status(400).json({ error });
Expand Down

0 comments on commit f4e9f38

Please sign in to comment.