diff options
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/oauth.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index b1149174b..bd60a3639 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { logger } from '../helpers/logger' | ||
3 | import { Socket } from 'socket.io' | 2 | import { Socket } from 'socket.io' |
4 | import { getAccessToken } from '../lib/oauth-model' | ||
5 | import { oAuthServer } from '@server/lib/auth' | 3 | import { oAuthServer } from '@server/lib/auth' |
4 | import { logger } from '../helpers/logger' | ||
5 | import { getAccessToken } from '../lib/oauth-model' | ||
6 | 6 | ||
7 | function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) { | 7 | function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) { |
8 | const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {} | 8 | const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {} |
@@ -24,7 +24,7 @@ function authenticate (req: express.Request, res: express.Response, next: expres | |||
24 | } | 24 | } |
25 | 25 | ||
26 | function authenticateSocket (socket: Socket, next: (err?: any) => void) { | 26 | function authenticateSocket (socket: Socket, next: (err?: any) => void) { |
27 | const accessToken = socket.handshake.query.accessToken | 27 | const accessToken = socket.handshake.query['accessToken'] |
28 | 28 | ||
29 | logger.debug('Checking socket access token %s.', accessToken) | 29 | logger.debug('Checking socket access token %s.', accessToken) |
30 | 30 | ||
@@ -38,7 +38,7 @@ function authenticateSocket (socket: Socket, next: (err?: any) => void) { | |||
38 | return next(new Error('Invalid access token.')) | 38 | return next(new Error('Invalid access token.')) |
39 | } | 39 | } |
40 | 40 | ||
41 | socket.handshake.query.user = tokenDB.User | 41 | socket.handshake.query['user'] = tokenDB.User |
42 | 42 | ||
43 | return next() | 43 | return next() |
44 | }) | 44 | }) |