Fake auth
Some checks failed
4NK Template Sync / check-and-sync (push) Has been cancelled

This commit is contained in:
omaroughriss 2026-01-13 17:39:16 +01:00
parent aedd3b9f10
commit f6094cff4b
3 changed files with 35 additions and 31 deletions

View File

@ -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,7 +77,11 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
role: "Administrateur",
company: "Entreprise Démo (ID: 1234)",
})
} else {
return
}
setIsMockMode(false)
// Vérifier la validité du token en mode production
const isValid = await messageBus.validateToken()
if (isValid) {
@ -90,7 +97,6 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
} else {
setIsAuthModalOpen(true)
}
}
} else {
setIsAuthModalOpen(true)
}

View File

@ -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
View File

@ -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",