@@ -19,6 +19,14 @@ window.GetAuthDetails = async () => {
1919
2020 // Check if the request is successful
2121 if ( ! authResponse . ok ) {
22+ if ( getStoredData ( 'authEnabled' ) === 'false' ) {
23+ //Authentication is disabled. Will use mock user
24+ console . log ( "Authentication Disabled. Using mock user details." ) ;
25+
26+ const headers = getMockUserHeaders ( ) ;
27+
28+ return headers ;
29+ }
2230 console . log ( "Failed to fetch authentication details. Access to chat will be blocked." ) ;
2331 return null ;
2432 }
@@ -47,25 +55,30 @@ window.GetAuthDetails = async () => {
4755 // This code runs locally so setup mock headers
4856 console . log ( "Running locally. Skipping authentication details fetch." ) ;
4957
58+ const headers = getMockUserHeaders ( ) ;
59+
60+ return headers ;
61+ }
62+
63+ function getMockUserHeaders ( ) {
5064 const mockUserDetails = {
5165 client_principal : 'mock-client-principal-id' ,
5266 user_claims : [
53- { typ : 'http://schemas.microsoft.com/identity/claims/objectidentifier' , val : '12345678-abcd-efgh-ijkl-9876543210ab' } , // Mock Object ID
54- { typ : 'name' , val : 'Local User' } , // Mock Name
55- { typ :
'email' , val :
'[email protected] ' } , // Mock Email (optional claim) 67+ { typ : 'http://schemas.microsoft.com/identity/claims/objectidentifier' , val : '12345678-abcd-efgh-ijkl-9876543210ab' } , // Mock Object ID
68+ { typ : 'name' , val : 'Local User' } , // Mock Name
69+ { typ :
'email' , val :
'[email protected] ' } , // Mock Email (optional claim) 5670 ] ,
5771 identity_provider : 'mock-identity-provider' , // Mock Identity Provider
58- } ;
59-
60- const headers = {
72+ } ;
73+
74+ const headers = {
6175 'Content-Type' : 'application/json' ,
6276 'X-Ms-Client-Principal' : mockUserDetails . client_principal || '' ,
6377 'X-Ms-Client-Principal-Id' : mockUserDetails . user_claims ?. find ( claim => claim . typ === 'http://schemas.microsoft.com/identity/claims/objectidentifier' ) ?. val || '' ,
6478 'X-Ms-Client-Principal-Name' : mockUserDetails . user_claims ?. find ( claim => claim . typ === 'name' ) ?. val || '' ,
6579 'X-Ms-Client-Principal-Idp' : mockUserDetails . identity_provider || '' ,
66- } ;
67-
68- return headers ;
80+ } ;
81+ return headers ;
6982 }
7083} ;
7184
0 commit comments