(@Body('email') email: string)
| 58 | |
| 59 | @Post('request') |
| 60 | async requestLogin(@Body('email') email: string) { |
| 61 | if (!email || !email.includes('@')) { |
| 62 | throw new HttpException('Invalid email', HttpStatus.BAD_REQUEST); |
| 63 | } |
| 64 | |
| 65 | const existingUser = await prisma.user.findFirst(); |
| 66 | |
| 67 | let user = await prisma.user.findUnique({ where: { email } }); |
| 68 | |
| 69 | if (!user) { |
| 70 | // first user becomes admin |
| 71 | user = await prisma.user.create({ |
| 72 | data: { email, isAdmin: !existingUser }, |
| 73 | }); |
| 74 | } |
| 75 | |
| 76 | return this.authService.sendMagicLink(email); |
| 77 | } |
| 78 | |
| 79 | @Get('verify') |
| 80 | async verifyLogin(@Query('token') token: string, @Res() res: Response) { |
nothing calls this directly
no test coverage detected