course_web / backend /src /auth /auth.controller.ts
trae-bot
Fix all linting errors in frontend and backend
8268e91
raw
history blame contribute delete
936 Bytes
import {
Controller,
Post,
Body,
Get,
UseGuards,
Request,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { RegisterDto } from './dto/register.dto';
import { LoginDto } from './dto/login.dto';
import { JwtAuthGuard } from './guards/jwt-auth.guard';
@Controller('api/auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}
@Post('register')
async register(@Body() registerDto: RegisterDto) {
const data = await this.authService.register(registerDto);
return { success: true, data };
}
@Post('login')
async login(@Body() loginDto: LoginDto) {
const data = await this.authService.login(loginDto);
return { success: true, data };
}
@UseGuards(JwtAuthGuard)
@Get('profile')
async getProfile(@Request() req) {
const data = await this.authService.getProfile(req.user.userId);
return { success: true, data };
}
}