github client geree

This commit is contained in:
2026-01-16 16:55:57 +01:00
parent 7b29a4b123
commit 70797f6215
4 changed files with 118 additions and 12 deletions
+17 -4
View File
@@ -40,12 +40,25 @@ export class LoginWindow extends fenetre {
this.githubBtn.style.backgroundColor = "#24292e";
this.githubBtn.style.color = "white";
this.githubBtn.onclick = () => {
window.location.href = "/api/auth/github";
// Ouvre le OAuth GitHub dans une popup et reçoit le token via postMessage
const w = 600;
const h = 700;
const left = (screen.width - w) / 2;
const top = (screen.height - h) / 2;
const popup = window.open('/api/auth/github', 'githubOAuth', `width=${w},height=${h},left=${left},top=${top}`);
const listener = (ev) => {
if (ev.data && ev.data.token) {
localStorage.setItem('auth_token', ev.data.token);
this.message.innerText = 'Connexion GitHub réussie ! Bienvenue.';
this.message.style.color = '#3cff01';
window.removeEventListener('message', listener);
if (popup) popup.close();
}
};
window.addEventListener('message', listener, {once: true});
};
this.body.appendChild(this.githubBtn);
this.checkIfAlreadyLoggedIn(); //verifie si l'utilisateur est connecté au démarrage
}
@@ -152,4 +165,4 @@ export class LoginWindow extends fenetre {
this.switch.innerText = "S'inscrire";
}
}
}
}