Add login page and social login integration

- Implement `LoginPage`, `LoginForm`, and `SocialForm` components.
- Add language toggle and dynamic title support.
- Update `tsconfig.electron.json` for stricter settings.
- Add `electron-store` and associated types for token storage.
- Update `package.json` scripts and dependencies for Electron compatibility.
This commit is contained in:
natreex
2025-11-16 13:20:20 -05:00
parent c9cf99e166
commit 1e6ebba56d
15 changed files with 1492 additions and 12 deletions

View File

@@ -181,12 +181,33 @@ function ScribeContent() {
}
async function checkAuthentification(): Promise<void> {
const token: string | null = System.getCookie('token');
// Essayer de récupérer le token depuis electron-store en priorité
let token: string | null = null;
if (typeof window !== 'undefined' && window.electron) {
try {
token = await window.electron.getToken();
} catch (e) {
console.error('Error getting token from electron:', e);
}
}
// Fallback sur les cookies si pas d'Electron
if (!token) {
token = System.getCookie('token');
}
if (token) {
try {
const user: UserProps = await System.authGetQueryToServer<UserProps>('user/infos', token, locale);
if (!user) {
errorMessage(t("homePage.errors.userNotFound"));
// Token invalide, supprimer et logout
if (window.electron) {
await window.electron.removeToken();
window.electron.logout();
}
return;
}
setSession({
isConnected: true,
@@ -201,12 +222,19 @@ function ScribeContent() {
} else {
errorMessage(t("homePage.errors.authenticationError"));
}
// TODO: Afficher la fenêtre de login Electron
console.log('Pas de session - afficher login Electron');
// Token invalide/erreur auth, supprimer et logout
if (window.electron) {
await window.electron.removeToken();
window.electron.logout();
}
}
} else {
// TODO: Afficher la fenêtre de login Electron
console.log('Pas de token - afficher login Electron');
// Pas de token - en Electron cela ne devrait jamais arriver
// car main.ts vérifie le token avant d'ouvrir mainWindow
// Si on arrive ici, c'est une erreur - fermer et ouvrir login
if (window.electron) {
window.electron.logout();
}
}
}