260305:1654 20260305:1700 N8N bulid flow #2
All checks were successful
Build and Deploy / deploy (push) Successful in 3m12s
All checks were successful
Build and Deploy / deploy (push) Successful in 3m12s
This commit is contained in:
@@ -35,6 +35,7 @@ describe('AuthService', () => {
|
|||||||
|
|
||||||
const mockQueryBuilder = {
|
const mockQueryBuilder = {
|
||||||
addSelect: jest.fn().mockReturnThis(),
|
addSelect: jest.fn().mockReturnThis(),
|
||||||
|
leftJoinAndSelect: jest.fn().mockReturnThis(),
|
||||||
where: jest.fn().mockReturnThis(),
|
where: jest.fn().mockReturnThis(),
|
||||||
getOne: jest.fn().mockResolvedValue(mockUser),
|
getOne: jest.fn().mockResolvedValue(mockUser),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -90,16 +90,23 @@ export class AuthService {
|
|||||||
scope: 'Global',
|
scope: 'Global',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isBot = user.username === 'migration_bot';
|
||||||
|
const accessTokenExpiresIn = isBot
|
||||||
|
? '100y'
|
||||||
|
: (this.configService.get<string>('JWT_EXPIRATION') || '15m');
|
||||||
|
|
||||||
const accessToken = await this.jwtService.signAsync(payload, {
|
const accessToken = await this.jwtService.signAsync(payload, {
|
||||||
secret: this.configService.get<string>('JWT_SECRET'),
|
secret: this.configService.get<string>('JWT_SECRET'),
|
||||||
expiresIn: (this.configService.get<string>('JWT_EXPIRATION') ||
|
expiresIn: accessTokenExpiresIn as any,
|
||||||
'15m') as any,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const refreshTokenExpiresIn = isBot
|
||||||
|
? '100y'
|
||||||
|
: (this.configService.get<string>('JWT_REFRESH_EXPIRATION') || '7d');
|
||||||
|
|
||||||
const refreshToken = await this.jwtService.signAsync(payload, {
|
const refreshToken = await this.jwtService.signAsync(payload, {
|
||||||
secret: this.configService.get<string>('JWT_REFRESH_SECRET'),
|
secret: this.configService.get<string>('JWT_REFRESH_SECRET'),
|
||||||
expiresIn: (this.configService.get<string>('JWT_REFRESH_EXPIRATION') ||
|
expiresIn: refreshTokenExpiresIn as any,
|
||||||
'7d') as any,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// [P2-2] Store Refresh Token in DB
|
// [P2-2] Store Refresh Token in DB
|
||||||
|
|||||||
@@ -161,9 +161,11 @@ return [{ json: { config_loaded: true, timestamp: new Date().toISOString() }}];
|
|||||||
|
|
||||||
เนื่องจาก Free Plan ไม่สามารถซ่อน Sensitive Data ได้ทั้งหมด แนะนำให้:
|
เนื่องจาก Free Plan ไม่สามารถซ่อน Sensitive Data ได้ทั้งหมด แนะนำให้:
|
||||||
|
|
||||||
1. **สร้าง Dedicated User สำหรับ Migration เท่านั้น**
|
1. **สร้าง Dedicated User สำหรับ Migration เท่านั้น** (แนะนำใช้ชื่อ `migration_bot`)
|
||||||
2. **ใช้ Token ที่มีสิทธิ์จำกัด** (เฉพาะ API ที่จำเป็น)
|
2. **ใช้ Token ที่มีสิทธิ์จำกัด** (เฉพาะ API ที่จำเป็น)
|
||||||
3. **Rotate Token ทันทีหลัง Migration เสร็จ**
|
3. **Rotate Token ทันทีหลัง Migration เสร็จ**
|
||||||
|
4. **💡 หมายเหตุ:** Backend ระบบ DMS ได้ถูกตั้งค่าให้สร้าง Token แบบไม่มีวันหมดอายุ (100 ปี) สำหรับ User ชื่อ `migration_bot` โดยเฉพาะ เพื่อป้องกันปัญหา Token หมดอายุระหว่างที่ Workflow กำลังทำงานข้ามวัน
|
||||||
|
|
||||||
|
|
||||||
**Credentials (ถ้าใช้):**
|
**Credentials (ถ้าใช้):**
|
||||||
|
|
||||||
@@ -173,6 +175,20 @@ return [{ json: { config_loaded: true, timestamp: new Date().toISOString() }}];
|
|||||||
| LCBP3 Backend | HTTP Request | Import to Backend, Fetch Categories |
|
| LCBP3 Backend | HTTP Request | Import to Backend, Fetch Categories |
|
||||||
| MariaDB | MySQL | ทุก Database Node |
|
| MariaDB | MySQL | ทุก Database Node |
|
||||||
|
|
||||||
|
|
||||||
|
### ขั้นตอนที่ 3: วิธีการรับ MIGRATION_TOKEN
|
||||||
|
|
||||||
|
1. **เข้าสู่ระบบ DMS** ด้วยบัญชี `migration_bot` (หรือบัญชี Admin สำหรับทดสอบ)
|
||||||
|
2. กดปุ่ม `F12` เพื่อเปิด Developer Tools ของเบราว์เซอร์
|
||||||
|
3. ไปที่แท็บ **Network** (เครือข่าย)
|
||||||
|
4. ทำกิจกรรมใดกิจกรรมหนึ่งบนหน้าเว็บ (เช่น คลิกเปลี่ยนหน้าหรือโหลดข้อมูล)
|
||||||
|
5. คลิกดูรายละเอียดของ Request ใดก็ได้ที่เรียกไปยัง API
|
||||||
|
6. ภายใต้ส่วน **Request Headers** ให้มองหาแอตทริบิวต์ `Authorization`
|
||||||
|
7. ให้คัดลอกค่าที่ตามหลังตคำว่า `Bearer` (ซึงจะเป็นสายอักขระยาวๆ)
|
||||||
|
8. นำค่าดังกล่าวมาใส่ทดแทนในส่วนของค่าคอนฟิก `MIGRATION_TOKEN` ของ Node **Set Configuration**
|
||||||
|
|
||||||
|
*(หรือใช้เครื่องมือ API Testing เช่น Postman รันคำสั่ง `POST /api/auth/login` และนำตัวแปร `accessToken` จากผลลัพธ์มาใช้งานโดยตรง)*
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📌 ส่วนที่ 3: การเตรียม Database
|
## 📌 ส่วนที่ 3: การเตรียม Database
|
||||||
|
|||||||
Reference in New Issue
Block a user