260322:1648 Correct Coresspondence / Doing RFA / Correct CI
This commit is contained in:
@@ -39,7 +39,7 @@ LCBP3-DMS จัดการเอกสารสำคัญของโปร
|
||||
|
||||
**Chosen:** **JWT (JSON Web Tokens) with Bearer Token Strategy (Stored in LocalStorage via Zustand)**
|
||||
|
||||
*Note: Initial plan was HTTP-only cookies, but shifted to Bearer tokens to ease cross-domain Next.js to NestJS communication.*
|
||||
_Note: Initial plan was HTTP-only cookies, but shifted to Bearer tokens to ease cross-domain Next.js to NestJS communication._
|
||||
|
||||
```typescript
|
||||
// File: src/auth/auth.service.ts
|
||||
@@ -85,10 +85,7 @@ export class AuthService {
|
||||
if (!user) return null;
|
||||
|
||||
// Use bcrypt for password comparison
|
||||
const isValid = await bcrypt.compare(
|
||||
credentials.password,
|
||||
user.password_hash
|
||||
);
|
||||
const isValid = await bcrypt.compare(credentials.password, user.password_hash);
|
||||
|
||||
return isValid ? user : null;
|
||||
}
|
||||
@@ -99,7 +96,7 @@ export class AuthService {
|
||||
|
||||
**Strategy:** **bcrypt with salt rounds = 10 (Current implementation defaults to 10 via `genSalt()`)**
|
||||
|
||||
*Note: Code currently uses `bcrypt.genSalt()` without arguments, defaulting to 10 rounds. If 12 is strictly required, codebase needs updating.*
|
||||
_Note: Code currently uses `bcrypt.genSalt()` without arguments, defaulting to 10 rounds. If 12 is strictly required, codebase needs updating._
|
||||
|
||||
```typescript
|
||||
import * as bcrypt from 'bcrypt';
|
||||
@@ -112,10 +109,7 @@ async function hashPassword(password: string): Promise<string> {
|
||||
}
|
||||
|
||||
// Verify password
|
||||
async function verifyPassword(
|
||||
password: string,
|
||||
hash: string
|
||||
): Promise<boolean> {
|
||||
async function verifyPassword(password: string, hash: string): Promise<boolean> {
|
||||
return bcrypt.compare(password, hash);
|
||||
}
|
||||
```
|
||||
@@ -177,11 +171,7 @@ function encrypt(text: string): { encrypted: string; iv: string; tag: string } {
|
||||
}
|
||||
|
||||
function decrypt(encrypted: string, iv: string, tag: string): string {
|
||||
const decipher = crypto.createDecipheriv(
|
||||
algorithm,
|
||||
key,
|
||||
Buffer.from(iv, 'hex')
|
||||
);
|
||||
const decipher = crypto.createDecipheriv(algorithm, key, Buffer.from(iv, 'hex'));
|
||||
|
||||
decipher.setAuthTag(Buffer.from(tag, 'hex'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user