This commit is contained in:
parent
aedd3b9f10
commit
f6094cff4b
@ -41,6 +41,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
const iframeUrl = process.env.NEXT_PUBLIC_4NK_IFRAME_URL || "https://dev3.4nkweb.com"
|
||||
const isMockAuthEnabled = process.env.NODE_ENV !== "production"
|
||||
|
||||
const navigation = [
|
||||
{ name: "Tableau de bord", href: "/dashboard", icon: LayoutDashboard },
|
||||
@ -57,15 +58,17 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
try {
|
||||
const userStore = UserStore.getInstance()
|
||||
const accessToken = userStore.getAccessToken()
|
||||
const refreshToken = userStore.getRefreshToken()
|
||||
const messageBus = MessageBus.getInstance(iframeUrl)
|
||||
|
||||
if (accessToken) {
|
||||
// Vérifier si on est en mode mock
|
||||
// const mockMode = messageBus.isInMockMode()
|
||||
// setIsMockMode(mockMode)
|
||||
const isMockSession =
|
||||
accessToken === "mock_access_token" &&
|
||||
refreshToken === "mock_refresh_token"
|
||||
|
||||
if (true) {
|
||||
if (isMockAuthEnabled && isMockSession) {
|
||||
console.log("🎭 Dashboard en mode mock")
|
||||
setIsMockMode(true)
|
||||
setIsAuthenticated(true)
|
||||
setUserInfo({
|
||||
id: "mock_user_001",
|
||||
@ -74,22 +77,25 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
role: "Administrateur",
|
||||
company: "Entreprise Démo (ID: 1234)",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
setIsMockMode(false)
|
||||
|
||||
// Vérifier la validité du token en mode production
|
||||
const isValid = await messageBus.validateToken()
|
||||
if (isValid) {
|
||||
setIsAuthenticated(true)
|
||||
const pairingId = userStore.getUserPairingId()
|
||||
setUserInfo({
|
||||
id: pairingId?.slice(0, 8) + "...",
|
||||
name: "Utilisateur 4NK",
|
||||
email: "user@4nk.io",
|
||||
role: "Utilisateur",
|
||||
company: "Organisation 4NK",
|
||||
})
|
||||
} else {
|
||||
// Vérifier la validité du token en mode production
|
||||
const isValid = await messageBus.validateToken()
|
||||
if (isValid) {
|
||||
setIsAuthenticated(true)
|
||||
const pairingId = userStore.getUserPairingId()
|
||||
setUserInfo({
|
||||
id: pairingId?.slice(0, 8) + "...",
|
||||
name: "Utilisateur 4NK",
|
||||
email: "user@4nk.io",
|
||||
role: "Utilisateur",
|
||||
company: "Organisation 4NK",
|
||||
})
|
||||
} else {
|
||||
setIsAuthModalOpen(true)
|
||||
}
|
||||
setIsAuthModalOpen(true)
|
||||
}
|
||||
} else {
|
||||
setIsAuthModalOpen(true)
|
||||
|
||||
@ -26,6 +26,7 @@ export default function LoginPage() {
|
||||
const router = useRouter()
|
||||
|
||||
const iframeUrl = process.env.NEXT_PUBLIC_4NK_IFRAME_URL || "https://dev3.4nkweb.com"
|
||||
const isMockAuthEnabled = process.env.NODE_ENV !== "production"
|
||||
|
||||
// Vérifier l'état de connexion au chargement
|
||||
useState(() => {
|
||||
@ -34,6 +35,13 @@ export default function LoginPage() {
|
||||
})
|
||||
|
||||
const handleLogin = () => {
|
||||
if (isMockAuthEnabled) {
|
||||
const userStore = UserStore.getInstance()
|
||||
userStore.connect("mock_access_token", "mock_refresh_token")
|
||||
router.push("/dashboard")
|
||||
return
|
||||
}
|
||||
|
||||
setIsAuthModalOpen(true)
|
||||
setError(null)
|
||||
}
|
||||
|
||||
14
package-lock.json
generated
14
package-lock.json
generated
@ -3732,7 +3732,6 @@
|
||||
"integrity": "sha512-EhBeSYX0Y6ye8pNebpKrwFJq7BoQ8J5SO6NlvNwwHjSj6adXJViPQrKlsyPw7hLBLvckEMO1yxeGdR82YBBlDg==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"csstype": "^3.0.2"
|
||||
}
|
||||
@ -3743,7 +3742,6 @@
|
||||
"integrity": "sha512-i5ZzwYpqjmrKenzkoLM2Ibzt6mAsM7pxB6BCIouEVVmgiqaMj1TjaK7hnA36hbW5aZv20kx7Lw6hWzPWg0Rurw==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"peerDependencies": {
|
||||
"@types/react": "^19.0.0"
|
||||
}
|
||||
@ -3823,7 +3821,6 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"caniuse-lite": "^1.0.30001733",
|
||||
"electron-to-chromium": "^1.5.199",
|
||||
@ -4151,8 +4148,7 @@
|
||||
"version": "8.5.1",
|
||||
"resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.5.1.tgz",
|
||||
"integrity": "sha512-JUb5+FOHobSiWQ2EJNaueCNT/cQU9L6XWBbWmorWPQT9bkbk+fhsuLr8wWrzXKagO3oWszBO7MSx+GfaRk4E6A==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/embla-carousel-react": {
|
||||
"version": "8.5.1",
|
||||
@ -4632,7 +4628,6 @@
|
||||
"resolved": "https://registry.npmjs.org/next/-/next-15.2.4.tgz",
|
||||
"integrity": "sha512-VwL+LAaPSxEkd3lU2xWbgEOtrM8oedmyhBqaVNmgKB+GvZlCy9rgaEc+y2on0wv+l0oSFqLtYD6dcC1eAedUaQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@next/env": "15.2.4",
|
||||
"@swc/counter": "0.1.3",
|
||||
@ -4778,7 +4773,6 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.11",
|
||||
"picocolors": "^1.1.1",
|
||||
@ -4816,7 +4810,6 @@
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.1.1.tgz",
|
||||
"integrity": "sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
@ -4847,7 +4840,6 @@
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.1.tgz",
|
||||
"integrity": "sha512-Dlq/5LAZgF0Gaz6yiqZCf6VCcZs1ghAJyrsu84Q/GT0gV+mCxbfmKNoGRKBYMJ8IEdGPqu49YWXD02GCknEDkw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"scheduler": "^0.26.0"
|
||||
},
|
||||
@ -4860,7 +4852,6 @@
|
||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.62.0.tgz",
|
||||
"integrity": "sha512-7KWFejc98xqG/F4bAxpL41NB3o1nnvQO1RWZT3TqRZYL8RryQETGfEdVnJN2fy1crCiBLLjkRBVK05j24FxJGA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
@ -5153,8 +5144,7 @@
|
||||
"version": "4.1.11",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.11.tgz",
|
||||
"integrity": "sha512-2E9TBm6MDD/xKYe+dvJZAmg3yxIEDNRc0jwlNyDg/4Fil2QcSLjFKGVff0lAf1jjeaArlG/M75Ey/EYr/OJtBA==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tailwindcss-animate": {
|
||||
"version": "1.0.7",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user