create-mikstack 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/base/src/hooks.server.ts +5 -1
- package/templates/base/src/lib/server/emails/magic-link.ts +7 -4
- package/templates/base/src/routes/{+layout.server.ts → (app)/+layout.server.ts} +1 -1
- package/templates/base/src/routes/(app)/+layout.svelte +30 -0
- package/templates/base/src/routes/api/dev/emails/[id]/+server.ts +2 -2
- package/templates/base/src/routes/+page.server.ts +0 -7
- /package/templates/base/src/routes/{+layout.ts → (app)/+layout.ts} +0 -0
- /package/templates/base/src/routes/{+page.svelte → (app)/+page.svelte} +0 -0
- /package/templates/base/src/routes/{sign-in → (public)/sign-in}/+page.svelte +0 -0
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { redirect, type Handle } from "@sveltejs/kit";
|
|
2
2
|
import { auth } from "$lib/server/auth";
|
|
3
3
|
import { svelteKitHandler } from "better-auth/svelte-kit";
|
|
4
4
|
import { building } from "$app/environment";
|
|
@@ -11,5 +11,9 @@ export const handle: Handle = async ({ event, resolve }) => {
|
|
|
11
11
|
event.locals.user = session?.user ?? null;
|
|
12
12
|
event.locals.session = session?.session ?? null;
|
|
13
13
|
|
|
14
|
+
if (event.route.id?.startsWith("/(app)") && !event.locals.user) {
|
|
15
|
+
redirect(302, "/sign-in");
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
return svelteKitHandler({ event, resolve, auth, building });
|
|
15
19
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { html, body, section, text, button,
|
|
1
|
+
import { html, body, section, text, button, render } from "@mikstack/email";
|
|
2
2
|
|
|
3
3
|
export function magicLinkEmail(url: string) {
|
|
4
4
|
const email = html(
|
|
@@ -13,11 +13,14 @@ export function magicLinkEmail(url: string) {
|
|
|
13
13
|
marginBottom: 40,
|
|
14
14
|
marginTop: 40,
|
|
15
15
|
}),
|
|
16
|
-
|
|
16
|
+
button("Sign in", {
|
|
17
17
|
href: url,
|
|
18
|
-
|
|
18
|
+
backgroundColor: "#111827",
|
|
19
|
+
color: "#ffffff",
|
|
19
20
|
fontSize: 14,
|
|
20
|
-
|
|
21
|
+
fontWeight: "bold",
|
|
22
|
+
padding: [12, 34],
|
|
23
|
+
borderRadius: 6,
|
|
21
24
|
marginBottom: 16,
|
|
22
25
|
}),
|
|
23
26
|
text("Or, copy and paste this temporary login URL:", {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { LayoutData } from "./$types";
|
|
4
|
+
import { Z } from "zero-svelte";
|
|
5
|
+
import { PUBLIC_SERVER } from "$env/static/public";
|
|
6
|
+
import { schema } from "$lib/zero/schema";
|
|
7
|
+
import { mutators } from "$lib/zero/mutators";
|
|
8
|
+
import { set_z } from "$lib/z.svelte";
|
|
9
|
+
|
|
10
|
+
let { data, children }: { data: LayoutData; children: Snippet } = $props();
|
|
11
|
+
|
|
12
|
+
set_z(
|
|
13
|
+
new Z({
|
|
14
|
+
get userID() {
|
|
15
|
+
return data.user.id;
|
|
16
|
+
},
|
|
17
|
+
server: PUBLIC_SERVER,
|
|
18
|
+
schema,
|
|
19
|
+
mutators,
|
|
20
|
+
kvStore: "idb",
|
|
21
|
+
context: {
|
|
22
|
+
get userID() {
|
|
23
|
+
return data.user.id;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
{@render children()}
|
|
@@ -23,8 +23,8 @@ export const GET: RequestHandler = async ({ params }) => {
|
|
|
23
23
|
|
|
24
24
|
const wrapper = `<!DOCTYPE html>
|
|
25
25
|
<html>
|
|
26
|
-
<head><meta charset="utf-8">${title}<style>*{margin:0;padding:0}html,body{
|
|
27
|
-
<body><iframe srcdoc="${escaped}"></iframe></body>
|
|
26
|
+
<head><meta charset="utf-8">${title}<style>*{margin:0;padding:0}html,body{background:#e5e7eb}iframe{display:block;max-width:600px;width:100%;margin:24px auto;border:none;background:#fff}</style></head>
|
|
27
|
+
<body><iframe srcdoc="${escaped}" onload="this.style.height=this.contentDocument.documentElement.scrollHeight+'px'"></iframe></body>
|
|
28
28
|
</html>`;
|
|
29
29
|
|
|
30
30
|
return new Response(wrapper, {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|