Create pr-full-lifecycle.yml - #221
Closed
zyntromedia wants to merge 1 commit into
Closed
zyntromedia wants to merge 1 commit into
zyntromedia wants to merge 1 commit into
Conversation
Signed-off-by: Zyntro-Agents <zyntro.ai.studio@gmail.com>
Contributor
|
ปิด PR นี้ — ยังไม่พร้อม merge เหตุผลหลัก:
หมายเหตุ: PR body ใส่โค้ด NestJS/Express AuthController ซึ่งไม่เกี่ยวข้องกับ repo Python/FastAPI นี้เลย หากต้องการ workflow แบบ full-lifecycle จริง แนะนำเริ่มใหม่โดย: SHA-pin ทุก action, ตัด dependency กับ |
zyntromedia
added a commit
that referenced
this pull request
Sep 13, 2026
feat #221 Signed-off-by: Zyntro-Agents <zyntro.ai.studio@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
import { Controller, Post, Body, UseGuards, Request, Get, HttpCode, HttpStatus } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth, ApiResponse } from '@nestjs/swagger';
import { AuthService } from './auth.service';
import { LocalAuthGuard } from './guards/local-auth.guard';
import { JwtAuthGuard } from './guards/jwt-auth.guard';
import { LoginDto } from './dto/login.dto';
import { RefreshDto } from './dto/refresh.dto';
import { Request as ExpressRequest } from 'express';
type AuthenticatedRequest = ExpressRequest & { user: { userId: string; [key: string]: any } };
@apitags('Authentication')
@controller('auth')
export class AuthController {
constructor(private authService: AuthService) {}
@post('login')
@UseGuards(LocalAuthGuard)
@apioperation({ summary: 'เข้าสู่ระบบด้วยอีเมล/รหัสผ่าน' })
@apiresponse({ status: 200, description: 'สำเร็จ — คืนโทเค็น' })
@apiresponse({ status: 401, description: 'ข้อมูลไม่ถูกต้อง' })
@httpcode(HttpStatus.OK)
async login(@Body() dto: LoginDto) {
const user = await this.authService.validateUser(dto.email, dto.password);
return this.authService.login(user);
}
@post('refresh')
@apioperation({ summary: 'ต่ออายุโทเค็น' })
@apiresponse({ status: 200, description: 'โทเค็นใหม่' })
@httpcode(HttpStatus.OK)
async refresh(@Body() dto: RefreshDto) {
return this.authService.refresh(dto.userId, dto.refreshToken);
}
@post('logout')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@apioperation({ summary: 'ออกจากระบบ & ยกเลิกโทเค็น' })
@apiresponse({ status: 204, description: 'ออกจากระบบสำเร็จ' })
@httpcode(HttpStatus.NO_CONTENT)
async logout(@request() req: AuthenticatedRequest): Promise {
await this.authService.logout(req.user.userId);
}
@get('me')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@apioperation({ summary: 'ดึงข้อมูลผู้ใช้ปัจจุบัน' })
@apiresponse({ status: 200, description: 'ข้อมูลผู้ใช้' })
@apiresponse({ status: 401, description: 'ไม่ได้รับอนุญาต' })
getProfile(@request() req: AuthenticatedRequest) {
return req.user;
}
}