diff options
Diffstat (limited to 'server/controllers/sessions.controller.ts')
-rw-r--r-- | server/controllers/sessions.controller.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/server/controllers/sessions.controller.ts b/server/controllers/sessions.controller.ts new file mode 100644 index 0000000..884ad3c --- /dev/null +++ b/server/controllers/sessions.controller.ts @@ -0,0 +1,27 @@ +import { Body, Controller, Post, Res } from '@nestjs/common'; +import { UsersService } from 'server/providers/services/users.service'; +import { SignInDto } from '../dto/sign_in.dto'; +import { Response } from 'express'; +// this is kind of a misnomer because we are doing token based auth +// instead of session based auth +@Controller() +export class SessionsController { + constructor(private usersService: UsersService) {} + + @Post('/sign_in') + async signIn(@Body() body: SignInDto, @Res() res: Response) { + console.log("DO I GET RAN?") + const verified = await this.usersService.verify( + body.username, + body.password, + ); + + if (!verified) { + res.status(400); + console.log("here too??") + res.json({ message: 'Invalid email or password' }); + return; + } + res.json({ success: true }); + } +} |