@@ -6,7 +6,7 @@ import { UserService } from '@/services/user.service';
66import { InvalidTokenError , TokenExpiredError } from '@/exception/token.exception' ;
77import { NotFoundError } from '@/exception' ;
88
9- type Token32 = string & { __lengthBrand : 10 } ;
9+ type Token10 = string & { __lengthBrand : 10 } ;
1010
1111export class UserController {
1212 constructor ( private userService : UserService ) { }
@@ -116,11 +116,11 @@ export class UserController {
116116 ) => {
117117 try {
118118 const user = req . user ;
119- const ip = req . ip ?? '' ;
119+ const ip = typeof req . headers [ 'x-forwarded-for' ] === 'string' ? req . headers [ 'x-forwarded-for' ] . split ( ',' ) [ 0 ] . trim ( ) : req . ip ?? '' ;
120120 const userAgent = req . headers [ 'user-agent' ] || '' ;
121121
122122 const token = await this . userService . create ( user . id , ip , userAgent ) ;
123- const typedToken = token as Token32 ;
123+ const typedToken = token as Token10 ;
124124
125125 const response = new QRLoginTokenResponseDto (
126126 true ,
@@ -130,7 +130,7 @@ export class UserController {
130130 ) ;
131131 res . status ( 200 ) . json ( response ) ;
132132 } catch ( error ) {
133- logger . error ( ' QR 토큰 생성 실패:' , error ) ;
133+ logger . error ( ` QR 토큰 생성 실패: [userId: ${ req . user ?. id || 'anonymous' } ]` , error ) ;
134134 next ( error ) ;
135135 }
136136 } ;
@@ -164,7 +164,7 @@ export class UserController {
164164
165165 res . redirect ( '/main' ) ;
166166 } catch ( error ) {
167- logger . error ( ' QR 토큰 로그인 처리 실패' , error ) ;
167+ logger . error ( ` QR 토큰 로그인 처리 실패: [userId: ${ req . user ?. id || 'anonymous' } ]` , error ) ;
168168 next ( error ) ;
169169 }
170170 } ;
0 commit comments