Fix jwt-token
This commit is contained in:
@@ -2,7 +2,6 @@ import React from 'react';
|
||||
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
|
||||
import { Toaster } from 'react-hot-toast';
|
||||
import { AuthProvider } from './contexts/AuthContext';
|
||||
import { MultiTenantAuthProvider } from './contexts/MultiTenantAuthContext';
|
||||
import { SocketProvider } from './contexts/SocketContext';
|
||||
import APP_CONFIG from './config/app';
|
||||
import Layout from './components/Layout';
|
||||
@@ -19,7 +18,6 @@ import ProtectedRoute from './components/ProtectedRoute';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<MultiTenantAuthProvider>
|
||||
<AuthProvider>
|
||||
<SocketProvider>
|
||||
<Router basename={APP_CONFIG.basePath}>
|
||||
@@ -83,7 +81,6 @@ function App() {
|
||||
</Router>
|
||||
</SocketProvider>
|
||||
</AuthProvider>
|
||||
</MultiTenantAuthProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from 'react';
|
||||
import { io } from 'socket.io-client';
|
||||
import { useAuth } from './AuthContext';
|
||||
import { useMultiTenantAuth } from './MultiTenantAuthContext';
|
||||
import toast from 'react-hot-toast';
|
||||
import APP_CONFIG from '../config/app';
|
||||
|
||||
@@ -17,8 +16,8 @@ export const SocketProvider = ({ children }) => {
|
||||
const [notificationsEnabled, setNotificationsEnabled] = useState(
|
||||
localStorage.getItem('notificationsEnabled') !== 'false' // Default to enabled
|
||||
);
|
||||
const { isAuthenticated } = useAuth();
|
||||
const { state: { tenant } } = useMultiTenantAuth();
|
||||
const { isAuthenticated, user } = useAuth();
|
||||
const tenant = user?.tenant_id;
|
||||
|
||||
// Mobile notification management
|
||||
const [notificationCooldown, setNotificationCooldown] = useState(new Map());
|
||||
@@ -141,6 +140,8 @@ export const SocketProvider = ({ children }) => {
|
||||
if (tenant) {
|
||||
newSocket.emit('join_tenant_room', tenant);
|
||||
console.log(`🔒 Joined tenant room: ${tenant}`);
|
||||
} else {
|
||||
console.warn('⚠️ No tenant available for Socket.IO room isolation');
|
||||
}
|
||||
|
||||
toast.success('Connected to real-time updates');
|
||||
|
||||
Reference in New Issue
Block a user