File tree 5 files changed +23
-2
lines changed
5 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -42,5 +42,14 @@ module.exports = {
42
42
. catch ( err => {
43
43
res . status ( err . status || 500 )
44
44
. send ( util . successFalse ( err . status , err . message ) ) } )
45
+ } ,
46
+ refresh : async ( req , res ) => {
47
+ User . refreshToken ( req . body )
48
+ . then ( result =>
49
+ res . status ( status . OK )
50
+ . send ( util . successTrue ( status . OK , message . REFRESH_TOKEN_SUCCESS , result ) ) )
51
+ . catch ( err => {
52
+ res . status ( err . status || 500 )
53
+ . send ( util . successFalse ( err . status , err . message ) ) } )
45
54
}
46
55
}
Original file line number Diff line number Diff line change @@ -70,5 +70,14 @@ module.exports = {
70
70
const value = [ phoneNum , userIdx ] ;
71
71
const result = await db . queryParam_Parse ( query , value ) ;
72
72
return result ;
73
+ } ,
74
+ refreshToken : async ( { uuid} ) => {
75
+ const findUserQuery = `SELECT * FROM ${ TABLE } WHERE uuid = ?` ;
76
+ const findUserValues = [ uuid ] ;
77
+ const findUserResult = await db . queryParam_Parse ( findUserQuery , findUserValues ) ;
78
+ const user = findUserResult [ 0 ] ;
79
+ const userIdx = user . userIdx ;
80
+ const jwtToken = jwtExt . publish ( { userIdx, uuid} ) ;
81
+ return { token :jwtToken . token } ;
73
82
}
74
83
}
Original file line number Diff line number Diff line change @@ -28,13 +28,13 @@ module.exports = {
28
28
} catch ( err ) {
29
29
if ( err . message === 'jwt expired' ) {
30
30
console . log ( 'expired token' ) ;
31
- return - 3 ;
31
+ return - 1 ;
32
32
} else if ( err . message === 'invalid token' ) {
33
33
console . log ( 'invalid token' ) ;
34
34
return - 2 ;
35
35
} else {
36
36
console . log ( 'other problem' ) ;
37
- return - 2 ;
37
+ return - 3 ;
38
38
}
39
39
}
40
40
return decoded ;
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ module.exports = {
17
17
USER_UPDATE_FAIL :"유저 추가 실패" ,
18
18
EXIST_DATA : "데이터가 있습니다." ,
19
19
NO_DATA :"데이터가 없습니다." ,
20
+ REFRESH_TOKEN_SUCCESS :"리프래시 토큰 성공" ,
21
+ REFRESH_TOKEN_FAIL :"리프래시 토큰 실패" ,
20
22
21
23
PHONE_NUM_UPDATE_SUCCESS : "전화번호 변경 성공" ,
22
24
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const {LoggedIn} = require('../modules/utils/authUtil');
5
5
6
6
router . post ( '/start' , AuthControllers . start ) ;
7
7
router . post ( '/signIn' , AuthControllers . signIn ) ;
8
+ router . get ( '/refresh' , AuthControllers . refresh ) ;
8
9
router . put ( '/' , LoggedIn , AuthControllers . updatePwd )
9
10
router . put ( '/phone' , LoggedIn , AuthControllers . updatePhone ) ;
10
11
You can’t perform that action at this time.
0 commit comments