File tree Expand file tree Collapse file tree 1 file changed +6
-20
lines changed Expand file tree Collapse file tree 1 file changed +6
-20
lines changed Original file line number Diff line number Diff line change 11import "dotenv/config" ;
22import jwt from 'jsonwebtoken' ;
33
4- export function auth ( backendToken ) {
5- console . log ( "Backend Token" , backendToken ) ;
6-
7- if ( ! backendToken ) {
4+ export function auth ( token ) {
5+ if ( ! token ) {
86 return false ;
97 }
108
119 try {
12- const data = jwt . verify ( backendToken , process . env . APP_SECRET ) ;
13- console . log ( "Auth data" , data ) ;
14- return data ;
10+ return jwt . verify ( token , process . env . APP_SECRET ) ;
1511 } catch ( err ) {
16- console . log ( err ) ;
12+ console . warn ( err ) ;
1713 return false ;
1814 }
1915
2016 return true ;
21-
22- // if ("credentials" === provider) {
23- // return true;
24- // } else if ("keycloak" === provider) {
25- // return true;
26- // } else if ("livekit" === provider) {
27- // return true;
28- // }
29- //
30- // return false;
3117}
3218
3319export function httpAuthMiddleware ( req , res , next ) {
34- if ( ! auth ( req . query . backendToken ) ) {
20+ if ( ! auth ( req . query . token ) ) {
3521 return res . status ( 401 ) . json ( { error : "Unauthorized" } ) ;
3622 }
3723 next ( ) ;
3824}
3925
4026export function socketAuthMiddleware ( socket , next ) {
41- const userData = auth ( socket . handshake . query . backendToken ) ;
27+ const userData = auth ( socket . handshake . query . token ) ;
4228 if ( ! userData ) {
4329 return next ( new Error ( "Unauthorized" ) ) ;
4430 }
You can’t perform that action at this time.
0 commit comments