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 router = useRouter()
const pathname = usePathname() const pathname = usePathname()
const iframeUrl = process.env.NEXT_PUBLIC_4NK_IFRAME_URL || "https://dev3.4nkweb.com" const iframeUrl = process.env.NEXT_PUBLIC_4NK_IFRAME_URL || "https://dev3.4nkweb.com"
const isMockAuthEnabled = process.env.NODE_ENV !== "production"
const navigation = [ const navigation = [
{ name: "Tableau de bord", href: "/dashboard", icon: LayoutDashboard }, { name: "Tableau de bord", href: "/dashboard", icon: LayoutDashboard },
@ -57,15 +58,17 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
try { try {
const userStore = UserStore.getInstance() const userStore = UserStore.getInstance()
const accessToken = userStore.getAccessToken() const accessToken = userStore.getAccessToken()
const refreshToken = userStore.getRefreshToken()
const messageBus = MessageBus.getInstance(iframeUrl) const messageBus = MessageBus.getInstance(iframeUrl)
if (accessToken) { if (accessToken) {
// Vérifier si on est en mode mock const isMockSession =
// const mockMode = messageBus.isInMockMode() accessToken === "mock_access_token" &&
// setIsMockMode(mockMode) refreshToken === "mock_refresh_token"
if (true) { if (isMockAuthEnabled && isMockSession) {
console.log("🎭 Dashboard en mode mock") console.log("🎭 Dashboard en mode mock")
setIsMockMode(true)
setIsAuthenticated(true) setIsAuthenticated(true)
setUserInfo({ setUserInfo({
id: "mock_user_001", id: "mock_user_001",
@ -74,7 +77,11 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
role: "Administrateur", role: "Administrateur",
company: "Entreprise Démo (ID: 1234)", company: "Entreprise Démo (ID: 1234)",
}) })
} else { return
}
setIsMockMode(false)
// Vérifier la validité du token en mode production // Vérifier la validité du token en mode production
const isValid = await messageBus.validateToken() const isValid = await messageBus.validateToken()
if (isValid) { if (isValid) {
@ -90,7 +97,6 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
} else { } else {
setIsAuthModalOpen(true) setIsAuthModalOpen(true)
} }
}
} else { } else {
setIsAuthModalOpen(true) setIsAuthModalOpen(true)
} }

View File

@ -26,6 +26,7 @@ export default function LoginPage() {
const router = useRouter() const router = useRouter()
const iframeUrl = process.env.NEXT_PUBLIC_4NK_IFRAME_URL || "https://dev3.4nkweb.com" 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 // Vérifier l'état de connexion au chargement
useState(() => { useState(() => {
@ -34,6 +35,13 @@ export default function LoginPage() {
}) })
const handleLogin = () => { const handleLogin = () => {
if (isMockAuthEnabled) {
const userStore = UserStore.getInstance()
userStore.connect("mock_access_token", "mock_refresh_token")
router.push("/dashboard")
return
}
setIsAuthModalOpen(true) setIsAuthModalOpen(true)
setError(null) setError(null)
} }

14
package-lock.json generated
View File

@ -3732,7 +3732,6 @@
"integrity": "sha512-EhBeSYX0Y6ye8pNebpKrwFJq7BoQ8J5SO6NlvNwwHjSj6adXJViPQrKlsyPw7hLBLvckEMO1yxeGdR82YBBlDg==", "integrity": "sha512-EhBeSYX0Y6ye8pNebpKrwFJq7BoQ8J5SO6NlvNwwHjSj6adXJViPQrKlsyPw7hLBLvckEMO1yxeGdR82YBBlDg==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"csstype": "^3.0.2" "csstype": "^3.0.2"
} }
@ -3743,7 +3742,6 @@
"integrity": "sha512-i5ZzwYpqjmrKenzkoLM2Ibzt6mAsM7pxB6BCIouEVVmgiqaMj1TjaK7hnA36hbW5aZv20kx7Lw6hWzPWg0Rurw==", "integrity": "sha512-i5ZzwYpqjmrKenzkoLM2Ibzt6mAsM7pxB6BCIouEVVmgiqaMj1TjaK7hnA36hbW5aZv20kx7Lw6hWzPWg0Rurw==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"peerDependencies": { "peerDependencies": {
"@types/react": "^19.0.0" "@types/react": "^19.0.0"
} }
@ -3823,7 +3821,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"caniuse-lite": "^1.0.30001733", "caniuse-lite": "^1.0.30001733",
"electron-to-chromium": "^1.5.199", "electron-to-chromium": "^1.5.199",
@ -4151,8 +4148,7 @@
"version": "8.5.1", "version": "8.5.1",
"resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.5.1.tgz", "resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.5.1.tgz",
"integrity": "sha512-JUb5+FOHobSiWQ2EJNaueCNT/cQU9L6XWBbWmorWPQT9bkbk+fhsuLr8wWrzXKagO3oWszBO7MSx+GfaRk4E6A==", "integrity": "sha512-JUb5+FOHobSiWQ2EJNaueCNT/cQU9L6XWBbWmorWPQT9bkbk+fhsuLr8wWrzXKagO3oWszBO7MSx+GfaRk4E6A==",
"license": "MIT", "license": "MIT"
"peer": true
}, },
"node_modules/embla-carousel-react": { "node_modules/embla-carousel-react": {
"version": "8.5.1", "version": "8.5.1",
@ -4632,7 +4628,6 @@
"resolved": "https://registry.npmjs.org/next/-/next-15.2.4.tgz", "resolved": "https://registry.npmjs.org/next/-/next-15.2.4.tgz",
"integrity": "sha512-VwL+LAaPSxEkd3lU2xWbgEOtrM8oedmyhBqaVNmgKB+GvZlCy9rgaEc+y2on0wv+l0oSFqLtYD6dcC1eAedUaQ==", "integrity": "sha512-VwL+LAaPSxEkd3lU2xWbgEOtrM8oedmyhBqaVNmgKB+GvZlCy9rgaEc+y2on0wv+l0oSFqLtYD6dcC1eAedUaQ==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@next/env": "15.2.4", "@next/env": "15.2.4",
"@swc/counter": "0.1.3", "@swc/counter": "0.1.3",
@ -4778,7 +4773,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"nanoid": "^3.3.11", "nanoid": "^3.3.11",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
@ -4816,7 +4810,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-19.1.1.tgz", "resolved": "https://registry.npmjs.org/react/-/react-19.1.1.tgz",
"integrity": "sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==", "integrity": "sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
} }
@ -4847,7 +4840,6 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.1.tgz", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.1.tgz",
"integrity": "sha512-Dlq/5LAZgF0Gaz6yiqZCf6VCcZs1ghAJyrsu84Q/GT0gV+mCxbfmKNoGRKBYMJ8IEdGPqu49YWXD02GCknEDkw==", "integrity": "sha512-Dlq/5LAZgF0Gaz6yiqZCf6VCcZs1ghAJyrsu84Q/GT0gV+mCxbfmKNoGRKBYMJ8IEdGPqu49YWXD02GCknEDkw==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"scheduler": "^0.26.0" "scheduler": "^0.26.0"
}, },
@ -4860,7 +4852,6 @@
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.62.0.tgz", "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.62.0.tgz",
"integrity": "sha512-7KWFejc98xqG/F4bAxpL41NB3o1nnvQO1RWZT3TqRZYL8RryQETGfEdVnJN2fy1crCiBLLjkRBVK05j24FxJGA==", "integrity": "sha512-7KWFejc98xqG/F4bAxpL41NB3o1nnvQO1RWZT3TqRZYL8RryQETGfEdVnJN2fy1crCiBLLjkRBVK05j24FxJGA==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"
}, },
@ -5153,8 +5144,7 @@
"version": "4.1.11", "version": "4.1.11",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.11.tgz", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.11.tgz",
"integrity": "sha512-2E9TBm6MDD/xKYe+dvJZAmg3yxIEDNRc0jwlNyDg/4Fil2QcSLjFKGVff0lAf1jjeaArlG/M75Ey/EYr/OJtBA==", "integrity": "sha512-2E9TBm6MDD/xKYe+dvJZAmg3yxIEDNRc0jwlNyDg/4Fil2QcSLjFKGVff0lAf1jjeaArlG/M75Ey/EYr/OJtBA==",
"license": "MIT", "license": "MIT"
"peer": true
}, },
"node_modules/tailwindcss-animate": { "node_modules/tailwindcss-animate": {
"version": "1.0.7", "version": "1.0.7",