File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ export function createBaseHandler() {
6060
6161 // Add session to request
6262 baseHandler . use ( async ( req , res , next ) => {
63+ /** Handle authorization using either Bearer token auth or
64+ * using the next-auth session
65+ */
6366 if ( req . headers . authorization ) {
6467 // introspect the token
6568 const [ type , token ] = req . headers . authorization . split ( ' ' )
@@ -86,10 +89,11 @@ export function createBaseHandler() {
8689 throw Boom . badRequest ( 'Invalid token' )
8790 }
8891 }
89- }
90- const token = await getToken ( { req } )
91- if ( token ) {
92- req . session = { user_id : token . userId || token . sub }
92+ } else {
93+ const token = await getToken ( { req } )
94+ if ( token ) {
95+ req . session = { user_id : token . userId || token . sub }
96+ }
9397 }
9498 next ( )
9599 } )
You can’t perform that action at this time.
0 commit comments