Skip to content

Commit 35ac752

Browse files
committed
feat: find user by username
1 parent ae50bbd commit 35ac752

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

apps/api/src/sessions/sessions.service.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { accessibleQuery, InjectModel, LoggingService } from '@douglasneuroinformatics/libnest';
2-
import type { Model } from '@douglasneuroinformatics/libnest';
1+
import { accessibleQuery, InjectModel, InjectPrismaClient, LoggingService } from '@douglasneuroinformatics/libnest';
2+
import type { ExtendedPrismaClient, Model } from '@douglasneuroinformatics/libnest';
33
import { Injectable } from '@nestjs/common';
44
import { InternalServerErrorException, NotFoundException } from '@nestjs/common/exceptions';
55
import type { Group } from '@opendatacapture/schemas/group';
@@ -15,6 +15,7 @@ import { UsersService } from '@/users/users.service';
1515
@Injectable()
1616
export class SessionsService {
1717
constructor(
18+
@InjectPrismaClient() private readonly prismaClient: ExtendedPrismaClient,
1819
@InjectModel('Session') private readonly sessionModel: Model<'Session'>,
1920
private readonly groupsService: GroupsService,
2021
private readonly loggingService: LoggingService,
@@ -35,7 +36,12 @@ export class SessionsService {
3536
let user: null | Omit<User, 'hashedPassword'> = null;
3637

3738
if (userId) {
38-
user = await this.userService.findById(userId);
39+
user = await this.prismaClient.user.findUnique({
40+
where: {
41+
username: userId
42+
}
43+
});
44+
// user = await this.userService.findById(userId);
3945
}
4046

4147
// If the subject is not yet associated with the group, check it exists then append it

0 commit comments

Comments
 (0)