Initial commit, working app
This commit is contained in:
19
src/layouts/Base.astro
Normal file
19
src/layouts/Base.astro
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
interface Props {
|
||||
title?: string;
|
||||
}
|
||||
|
||||
const { title = "KarkarCar" } = Astro.props;
|
||||
---
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>{title}</title>
|
||||
</head>
|
||||
<body>
|
||||
<slot />
|
||||
</body>
|
||||
</html>
|
||||
3
src/pages/_app.astro
Normal file
3
src/pages/_app.astro
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
export const prerender = false;
|
||||
---
|
||||
@@ -1,16 +1,25 @@
|
||||
---
|
||||
import Layout from '../layouts/Base.astro';
|
||||
import type { Session } from '@auth/core/types';
|
||||
|
||||
import { getSession } from 'auth-astro/server';
|
||||
import { Auth, SignIn, SignOut } from 'auth-astro/components';
|
||||
|
||||
const session = await getSession(Astro.request);
|
||||
console.log(session);
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>Astro</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Astro</h1>
|
||||
</body>
|
||||
</html>
|
||||
<Auth>
|
||||
{(session: Session) => (
|
||||
console.log(session),
|
||||
<>
|
||||
{session ?
|
||||
<SignOut>Logout</SignOut>
|
||||
:
|
||||
<SignIn provider="keycloak">Login</SignIn>
|
||||
}
|
||||
<p>
|
||||
{session ? `Logged in as ${session.user?.name}` : 'Not logged in'}
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</Auth>
|
||||
Reference in New Issue
Block a user