Skip to content

Commit

Permalink
Fix teams2 (#78)
Browse files Browse the repository at this point in the history
* Fix leave hang

* Dont need team ID
  • Loading branch information
ryanlyrl committed Jan 29, 2021
1 parent 16c3eff commit 4912d5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/controllers/teamController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export const joinTeam = async (req: Request, res: Response): Promise<void> => {
const teamRepository = getManager().getRepository(Team);
const inviteRepo = getManager().getRepository(TeamInvite);

const teamId = req.params.teamId;
const inviteId = req.body.inviteId;
const token = req.header('Authorization')?.split(' ')[1];
if(!token) {
Expand All @@ -158,7 +157,8 @@ export const joinTeam = async (req: Request, res: Response): Promise<void> => {
return;
}

const team = await teamRepository.findOne({uuid: teamId});
const inviteObj = await inviteRepo.findOne({id: invite.id}, {relations: ['team']});
const team = inviteObj?.team;
if(!team){
res.status(404).send('That team does not exist.');
return;
Expand Down Expand Up @@ -195,7 +195,7 @@ export const leaveTeam = async (req: Request, res: Response): Promise<void> => {
res.sendStatus(401);
return;
}

if(!user.team) {
res.status(400).send('This user is not on a team.');
return;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ router.patch('/:teamId', team.changeName);
* @description Joins team with teamId, with invite ID in the body
* @response 200 - OK
*/
router.post('/:teamId/join', team.joinTeam);
router.post('/join', team.joinTeam);

export = router;

0 comments on commit 4912d5b

Please sign in to comment.