File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,7 @@ class SocketServer {
222
222
*/
223
223
middlewares ( ) {
224
224
const base = this ;
225
+
225
226
function wrapMiddleware ( middleware ) {
226
227
return ( socket , next ) => {
227
228
let nextCalled = false ;
@@ -366,9 +367,13 @@ class SocketServer {
366
367
/**
367
368
* Enforce that socket request is authenticated (no anonymous)
368
369
* @param {Object } socket Server socket
370
+ * @param {Function } next Call next
369
371
*/
370
372
enforceAuth ( socket , next ) {
371
- if ( cds . context ?. user ?. _is_anonymous || ( socket . request . isAuthenticated && ! socket . request . isAuthenticated ( ) ) ) {
373
+ if (
374
+ cds . context ?. user ?. _is_anonymous ||
375
+ ( typeof socket . request ?. isAuthenticated === "function" && ! socket . request ?. isAuthenticated ( ) )
376
+ ) {
372
377
const err = new Error ( "401" ) ;
373
378
err . code = 4401 ;
374
379
return next ( err ) ;
You can’t perform that action at this time.
0 commit comments