Skip to content

Commit aecfa01

Browse files
committed
fix: fix incorrect authorization logic
1 parent fb09959 commit aecfa01

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/proxy.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,26 @@ function createProxy(config: Config): Hono {
124124
return
125125
}
126126
} catch(e) {
127-
console.error(e)
128-
}
129-
130-
console.log('authorizing refresh token')
131-
await authorizeRefreshToken(refresh_token)
132-
.then(({
133-
access_token: refreshed_access_token,
134-
expires_in: refreshed_expires_in,
135-
refresh_token: refreshed_refresh_token,
136-
}) => {
137-
setCookie(c, 'access_token', refreshed_access_token, {
138-
maxAge: refreshed_expires_in,
139-
httpOnly: true,
127+
console.log('authorizing refresh token')
128+
await authorizeRefreshToken(refresh_token)
129+
.then(({
130+
access_token: refreshed_access_token,
131+
expires_in: refreshed_expires_in,
132+
refresh_token: refreshed_refresh_token,
133+
}) => {
134+
setCookie(c, 'access_token', refreshed_access_token, {
135+
maxAge: refreshed_expires_in,
136+
httpOnly: true,
137+
})
138+
setCookie(c, 'refresh_token', refreshed_refresh_token, {
139+
maxAge: refreshed_expires_in,
140+
httpOnly: true,
141+
})
140142
})
141-
setCookie(c, 'refresh_token', refreshed_refresh_token, {
142-
maxAge: refreshed_expires_in,
143-
httpOnly: true,
143+
.catch(e => {
144+
console.error(e)
144145
})
145-
})
146-
.catch(e => {
147-
console.error(e)
148-
})
146+
}
149147

150148
await next()
151149
})

0 commit comments

Comments
 (0)