Skip to content

Commit cf5f7af

Browse files
committed
fix: server auth
1 parent a71ab54 commit cf5f7af

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

docs/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ Authorization 헤더에 bearer로 refresh Token을 보냅니다.
9292

9393
## 사용자 정보 불러오기
9494

95+
```plain
96+
[GET] auth/user
97+
```
98+
9599
> 인증이 필요한 라우터입니다.
96100
97101
### Response
@@ -100,6 +104,7 @@ Authorization 헤더에 bearer로 refresh Token을 보냅니다.
100104
{
101105
"name": string,
102106
"email": string,
107+
"id": string
103108
}
104109
```
105110

@@ -350,6 +355,12 @@ Authorization 헤더에 bearer로 refresh Token을 보냅니다.
350355

351356
> 결제창 서버에서 인증을 위해 사용합니다.
352357
358+
나이스페이 요청 파라미터 중 `mallReserved`값에 id를 넣은 JSON을 추가해야합니다.
359+
360+
```plain
361+
'{"id":"cl6w0c3l20002no9zhxx22iqj"}'
362+
```
363+
353364
```plain
354365
[POST] /payment/serverAuth
355366
```

src/routers/auth/user/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export default async (req: Request, res: Response) => {
44
res.json({
55
name: req.user.name,
66
email: req.user.email,
7+
id: req.user.id
78
})
89
}

src/routers/payment/serverAuth/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ export default async (req: ServerAuthRequest, res: Response) => {
1616
throw new HttpError(500, response.resultMsg, response.resultCode)
1717
}
1818

19+
const userIdentity = JSON.parse(response.mallReserved) as {id: string}
20+
if(typeof userIdentity.id === 'undefined') {
21+
throw new HttpError(500, '잘못된 요청입니다.','ERR_INVALID_REQUEST')
22+
}
23+
1924
const transaction = await createTransaction({
2025
tid: response.tid,
2126
orderId: response.orderId,
2227
amount: response.amount,
2328
goodsName: response.goodsName,
24-
userId: req.user.id,
29+
userId: userIdentity.id,
2530
})
2631

2732
res.json(transaction)

0 commit comments

Comments
 (0)