tina
This commit is contained in:
27
tina/auth/oidc-provider.ts
Normal file
27
tina/auth/oidc-provider.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { AbstractAuthProvider } from "tinacms";
|
||||
|
||||
export class OIDCAuthProvider extends AbstractAuthProvider {
|
||||
async authenticate(): Promise<any> {
|
||||
window.location.href = "/auth/login";
|
||||
}
|
||||
|
||||
async getUser(): Promise<any> {
|
||||
// Appel à une route /api/me pour récupérer l'utilisateur
|
||||
const res = await fetch("/api/me", {
|
||||
credentials: "include",
|
||||
});
|
||||
if (res.ok) {
|
||||
return await res.json();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async getToken(): Promise<{ id_token: string }> {
|
||||
// Le token est géré par les cookies, pas besoin de le retourner
|
||||
return { id_token: "" };
|
||||
}
|
||||
|
||||
async logout(): Promise<void> {
|
||||
window.location.href = "/auth/logout";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user