Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ DATABASE_URL=postgresql://postgres:postgres@localhost:5434/macsync_db
PORT=3000
NODE_ENV=development

# Auth Configuration
JWT_SECRET=change-me
JWT_EXPIRES_IN=60m
VERIFICATION_CODE_EXPIRY_MIN=10
VERIFICATION_CODE_SECRET=change-me
# Optional password settings
BCRYPT_SALT_ROUNDS=10

# Email (SMTP)
SMTP_HOST=
SMTP_PORT=
SMTP_USER=
SMTP_PASS=
EMAIL_FROM=no-reply@mcmaster.ca

# Optional: run seed on startup if DB is empty (idempotent)
# RUN_SEED=true

Expand Down
151 changes: 151 additions & 0 deletions src/backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
"@nestjs/core": "^11.0.1",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/platform-fastify": "^11.1.12",
"bcryptjs": "^3.0.2",
"dotenv": "^17.2.3",
"drizzle-orm": "^0.45.1",
"jsonwebtoken": "^9.0.3",
"nodemailer": "^8.0.1",
"pg": "^8.18.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
Expand All @@ -47,7 +50,9 @@
"@nestjs/testing": "^11.0.1",
"@types/express": "^5.0.0",
"@types/jest": "^30.0.0",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^22.10.7",
"@types/nodemailer": "^7.0.9",
"@types/pg": "^8.16.0",
"@types/supertest": "^6.0.2",
"drizzle-kit": "^0.31.8",
Expand Down
2 changes: 2 additions & 0 deletions src/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AppService } from './app.service';
import { DatabaseModule } from './database/database.module';
import { UsersModule } from './users/users.module';
import { EventsModule } from './events/events.module';
import { AuthModule } from './auth/auth.module';
import { WebhooksModule } from './webhooks/webhooks.module';
import { PaymentsModule } from './payments/payments.module';
import { StatsModule } from './stats/stats.module';
Expand All @@ -15,6 +16,7 @@ import { StatsModule } from './stats/stats.module';
EventsModule,
WebhooksModule,
PaymentsModule,
AuthModule,
StatsModule,
],
controllers: [AppController],
Expand Down
75 changes: 75 additions & 0 deletions src/backend/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {
Body,
Controller,
Get,
Post,
Req,
UseGuards,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { JwtAuthGuard } from './jwt-auth.guard';
import { OnboardingGuard } from './onboarding.guard';

@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}

@Post('request-code')
requestCode(@Body('email') email: string) {
return this.authService.requestVerificationCode(email);
}

@Post('check-email')
checkEmail(@Body('email') email: string) {
return this.authService.checkEmail(email);
}

@Post('login')
login(@Body() body: { email: string; password: string }) {
return this.authService.loginWithPassword(body.email, body.password);
}

@Post('request-otp')
requestOtp(@Body('email') email: string) {
return this.authService.requestOtp(email);
}

@Post('verify-code')
verifyCode(@Body() body: { email: string; code: string }) {
return this.authService.verifyCode(body.email, body.code);
}

@Post('verify-otp')
verifyOtp(@Body() body: { email: string; code: string }) {
return this.authService.verifyOtp(body.email, body.code);
}

@Post('register')
@UseGuards(OnboardingGuard)
register(
@Body()
body: {
firstName: string;
lastName: string;
phone: string;

Check failure on line 54 in src/backend/src/auth/auth.controller.ts

View workflow job for this annotation

GitHub Actions / Backend

Unsafe member access .onboardingEmail on an `any` value

Check warning on line 54 in src/backend/src/auth/auth.controller.ts

View workflow job for this annotation

GitHub Actions / Backend

Unsafe argument of type `any` assigned to a parameter of type `string`
program: string;
password: string;
confirmPassword?: string;
},
@Req() req: any,
) {

Check failure on line 60 in src/backend/src/auth/auth.controller.ts

View workflow job for this annotation

GitHub Actions / Backend

Unsafe member access .user on an `any` value

Check warning on line 60 in src/backend/src/auth/auth.controller.ts

View workflow job for this annotation

GitHub Actions / Backend

Unsafe argument of type `any` assigned to a parameter of type `number`
return this.authService.registerUser(req.onboardingEmail, body);
}

@Get('me')
@UseGuards(JwtAuthGuard)
me(@Req() req: any) {
return this.authService.getUserInfo(req.user.sub);
}

@Post('logout')
@UseGuards(JwtAuthGuard)
logout() {
return { success: true };
}
}
13 changes: 13 additions & 0 deletions src/backend/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { DatabaseModule } from '../database/database.module';
import { UsersModule } from '../users/users.module';

@Module({
imports: [DatabaseModule, UsersModule],
controllers: [AuthController],
providers: [AuthService],
exports: [AuthService],
})
export class AuthModule {}
Loading
Loading