Skip to content

Commit 4cc70df

Browse files
jamesdufAlan-Cha
authored andcommitted
add cookie handling logic to middleware
Signed-off-by: jamesduf <[email protected]>
1 parent 896aeb5 commit 4cc70df

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/oasgraph/test/example_api_server.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,17 @@ function startServer (PORT) {
240240
message: 'Incorrect credentials'
241241
})
242242
return false
243-
} else if ('access_token' in req.query) {
243+
} else if ('cookie' in req.headers) {
244+
for (let user in Auth) {
245+
if (Auth[user].accessToken === req.headers.cookie.split('=')[1]) {
246+
return next()
247+
}
248+
}
249+
res.status(401).send({
250+
message: 'Incorrect credentials'
251+
})
252+
return false
253+
}else if ('access_token' in req.query) {
244254
for (let user in Auth) {
245255
if (Auth[user].accessToken === req.query.access_token) {
246256
return next()

0 commit comments

Comments
 (0)