feat(onboarding): assistant de configuration au premier lancement et visite guidée des écrans

This commit is contained in:
ElPouki committed 2026-09-14 13:46:51 +02:00
1 parent 6348cc40cb
commit 4b3c629ff9
43 files changed
+2498 -366

No files matched your search

+20
View File
@@ -19,6 +19,7 @@ export interface User {
role : UserRole
apiToken : string
createdAt : string
tourSeenAt? : string | null
}
const USERS_PATH = path.join(DATA_DIR, 'users.json')
@@ -92,6 +93,7 @@ export function createUser(username: string, password: string, role: UserRole =
role,
apiToken : crypto.randomBytes(32).toString('hex'),
createdAt : new Date().toISOString(),
tourSeenAt : null,
}
writeUsers([...users, user])
logger.info('users', `Utilisateur "${username}" créé (rôle: ${role})`)
@@ -142,6 +144,24 @@ export function changePassword(id: string, currentPassword: string, newPassword:
logger.info('users', `Mot de passe changé pour "${user.username}"`)
}
export function markTourSeen(id: string): string {
const users = readUsers()
const user = users.find(u => u.id === id)
if (!user) throw new Error('Utilisateur introuvable')
user.tourSeenAt = user.tourSeenAt ?? new Date().toISOString()
writeUsers(users)
return user.tourSeenAt
}
export function markAllToursSeen(at: string): number {
const users = readUsers()
const pending = users.filter(u => !u.tourSeenAt)
if (pending.length === 0) return 0
for (const u of pending) u.tourSeenAt = at
writeUsers(users)
return pending.length
}
export function regenerateApiToken(id: string): string {
const users = readUsers()
const user = users.find(u => u.id === id)