Skip to content
Snippets Groups Projects
Commit c5a17c37 authored by L4168's avatar L4168
Browse files

added path&service for verifying faction

parent 18e42bf5
No related branches found
No related tags found
3 merge requests!59Development to master,!36Development,!33Small fixes
...@@ -88,4 +88,11 @@ export class FactionController { ...@@ -88,4 +88,11 @@ export class FactionController {
) { ) {
return this.factionservice.joinFaction(person, data); return this.factionservice.joinFaction(person, data);
} }
// check if person belongs to a faction in a game
@Get('check-faction/:id')
@UseGuards(new AuthGuard())
checkFaction(@User('id') userId, @Param('id') gameId) {
return this.factionservice.verifyUser(userId, gameId);
}
} }
...@@ -129,4 +129,19 @@ export class FactionService { ...@@ -129,4 +129,19 @@ export class FactionService {
}); });
return members; return members;
} }
async verifyUser(person, game) {
const gameperson = await this.game_PersonRepository.findOne({
where: { person, game },
relations: ['faction'],
});
if (gameperson) {
return {
code: 200,
message: gameperson,
};
} else {
throw new HttpException('No faction was found', HttpStatus.BAD_REQUEST);
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment