Skip to content

Commit

Permalink
fix up jwt bootstrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherJMiller committed Jan 12, 2024
1 parent b7e02c5 commit 8e55e76
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api/src/groups/group.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export class GroupController {
@Get('groups/:id/members')
@ApiBearerAuth()
@ApiParam(groupIdParam)
groupMembers(@Param() params: GetByIdParameter): Promise<User[]> {
groupMembers(@Param() params: GetByIdParameter): Promise<User[] | undefined> {
return this.groupService
.findOneBy({ id: params.id })
.then((group) => group.users);
.then((group) => group?.users);
}

@UseGuards(AuthGuard('jwt'))
Expand Down
2 changes: 1 addition & 1 deletion api/src/groups/group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class GroupsService {
async findOneBy(group: Partial<Group>): Promise<Group | null> {
return this.groupsRepository.findOne({
where: group,
relations: ['users'],
relations: ['users', 'users.connections'],
});
}

Expand Down
12 changes: 7 additions & 5 deletions api/src/users/jwt.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
admin: User.fromJwt(jwt).admin,
});
} else {
console.log('Bootstrapping new user');
const user = User.fromJwt(jwt);
console.log('saving user');
this.userService.create(user);
console.log('saving connections');
this.connectionService.saveForUser(user, {});
if (user.displayName) {
console.log('Bootstrapping new user');
console.log('saving user');
this.userService.create(user);
console.log('saving connections');
this.connectionService.saveForUser(user, {});
}
}
})
.catch((e) => {
Expand Down

0 comments on commit 8e55e76

Please sign in to comment.