Skip to content

Create pr-full-lifecycle.yml - #221

Closed
zyntromedia wants to merge 1 commit into
mainfrom
main-1
Closed

zyntromedia wants to merge 1 commit into
mainfrom
main-1

Conversation

@zyntromedia

Copy link
Copy Markdown
Member

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;
}
}

Signed-off-by: Zyntro-Agents <zyntro.ai.studio@gmail.com>

@zyntromedia zyntromedia left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledge

@fig-ai-agent

fig-ai-agent Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

ปิด PR นี้ — ยังไม่พร้อม merge

เหตุผลหลัก:

  1. อ้าง local action ที่ไม่มีอยู่จริง: uses: ./.github/actions/analyze-pr แต่บน branch ไม่มีโฟลเดอร์ .github/actions/ ทำให้ job analyze-pr ตายตั้งแต่ step แรก และลาก job อื่นที่ needs ต่อกัน (security-gate → build-test → finalize) ตายตามทั้งหมด
  2. ผิดนโยบาย SHA-pinning ของ repo: ไฟล์ใช้ actions/checkout@v4, actions/setup-python@v5, gitleaks/gitleaks-action@v2, actions/dependency-review-action@v4 — org policy ฟันธงว่า all actions must be pinned to a full-length commit SHA (run ของ workflow นี้ถูกปฏิเสธก่อนเริ่ม โดยมี 0 job)
  3. อ้าง action ที่ไม่มีใน org: zyntroai/verify-sha-pin ไม่มีอยู่ (404)
  4. job build-test จะแดงแน่: รัน pytest --cov + flake8 แต่ root requirements.txt ไม่มี pytest / pytest-cov / flake8
  5. trigger ไม่ครบ: อ้าง branch develop ที่ไม่มีใน repo และ debug-ci เช็ค workflow_dispatch ที่ไม่ได้ประกาศใน on:
  6. ซ้ำกับ CI ที่มีอยู่แล้ว (ci.yml, test-suite.yml, test-and-coverage.yaml, secret-scan.yml, copilot-audit.yml)

หมายเหตุ: PR body ใส่โค้ด NestJS/Express AuthController ซึ่งไม่เกี่ยวข้องกับ repo Python/FastAPI นี้เลย

หากต้องการ workflow แบบ full-lifecycle จริง แนะนำเริ่มใหม่โดย: SHA-pin ทุก action, ตัด dependency กับ ./.github/actions/analyze-pr ออกหรือสร้าง composite action ให้มีจริง, ติดตั้ง test tooling ก่อนรัน pytest/flake8 และเช็คกับ CI เดิมก่อนว่าจะรวมหรือแทนที่

@fig-ai-agent fig-ai-agent Bot closed this Sep 12, 2026
@zyntromedia zyntromedia mentioned this pull request Sep 12, 2026
20 tasks
zyntromedia added a commit that referenced this pull request Sep 13, 2026
feat #221

Signed-off-by: Zyntro-Agents <zyntro.ai.studio@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant