@batijs/cli 0.0.443 → 0.0.445
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/dist/boilerplates/@batijs/auth0/files/$.env.js +5 -5
- package/dist/boilerplates/@batijs/auth0/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/authjs/files/$package.json.js +5 -5
- package/dist/boilerplates/@batijs/aws/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/aws/files/$package.json.js +9 -9
- package/dist/boilerplates/@batijs/aws/files/$tsconfig.json.js +3 -3
- package/dist/boilerplates/@batijs/biome/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/cloudflare/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/cloudflare/files/$tsconfig.json.js +3 -3
- package/dist/boilerplates/@batijs/cloudflare/files/$vite.config.ts.js +5 -5
- package/dist/boilerplates/@batijs/compiled/files/$package.json.js +5 -5
- package/dist/boilerplates/@batijs/compiled/files/$vite.config.ts.js +5 -5
- package/dist/boilerplates/@batijs/d1/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/d1/files/$package.json.js +7 -7
- package/dist/boilerplates/@batijs/d1/files/$tsconfig.json.js +3 -3
- package/dist/boilerplates/@batijs/d1/files/$wrangler.toml.js +1 -1
- package/dist/boilerplates/@batijs/d1-sqlite/files/$package.json.js +6 -12
- package/dist/boilerplates/@batijs/drizzle/files/$.env.js +3 -3
- package/dist/boilerplates/@batijs/drizzle/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/drizzle/files/$package.json.js +4 -16
- package/dist/boilerplates/@batijs/eslint/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/eslint/files/eslint.config.ts +5 -5
- package/dist/boilerplates/@batijs/express/files/$package.json.js +7 -7
- package/dist/boilerplates/@batijs/express/files/express-entry.ts +0 -24
- package/dist/boilerplates/@batijs/fastify/files/$package.json.js +8 -8
- package/dist/boilerplates/@batijs/fastify/files/fastify-entry.ts +0 -24
- package/dist/boilerplates/@batijs/firebase-auth/files/$.env.js +3 -3
- package/dist/boilerplates/@batijs/firebase-auth/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/firebase-auth/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/google-analytics/files/$.env.js +3 -3
- package/dist/boilerplates/@batijs/h3/files/$package.json.js +7 -7
- package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +0 -24
- package/dist/boilerplates/@batijs/hattip/files/$package.json.js +7 -7
- package/dist/boilerplates/@batijs/hattip/files/hattip-entry.ts +0 -24
- package/dist/boilerplates/@batijs/hono/files/$package.json.js +8 -8
- package/dist/boilerplates/@batijs/hono/files/$vite.config.ts.js +5 -5
- package/dist/boilerplates/@batijs/hono/files/hono-entry.ts +0 -24
- package/dist/boilerplates/@batijs/mantine/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/mantine/files/$package.json.js +8 -8
- package/dist/boilerplates/@batijs/panda-css/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/pnpm/files/$pnpm-workspace.yaml.js +3 -3
- package/dist/boilerplates/@batijs/prettier/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/prisma/files/$.env.js +3 -3
- package/dist/boilerplates/@batijs/prisma/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/prisma/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/react/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/react/files/$package.json.js +9 -9
- package/dist/boilerplates/@batijs/react/files/$tsconfig.json.js +3 -3
- package/dist/boilerplates/@batijs/react/files/$vite.config.ts.js +5 -5
- package/dist/boilerplates/@batijs/react/files/layouts/LayoutDefault.tsx +1 -1
- package/dist/boilerplates/@batijs/react/files/pages/+config.ts +1 -1
- package/dist/boilerplates/@batijs/react-sentry/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/sentry/files/$.env.js +4 -4
- package/dist/boilerplates/@batijs/sentry/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/sentry/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/sentry/files/$vite.config.ts.js +7 -7
- package/dist/boilerplates/@batijs/sentry/files/pages/$+client.ts.js +7 -7
- package/dist/boilerplates/@batijs/shadcn-ui/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/shadcn-ui/files/$package.json.js +7 -7
- package/dist/boilerplates/@batijs/shadcn-ui/files/$tsconfig.json.js +3 -3
- package/dist/boilerplates/@batijs/shadcn-ui/files/$vite.config.ts.js +5 -5
- package/dist/boilerplates/@batijs/shared/files/$README.md.js +9 -9
- package/dist/boilerplates/@batijs/shared-server/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/solid/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/solid/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/solid/files/$tsconfig.json.js +3 -3
- package/dist/boilerplates/@batijs/solid/files/$vite.config.ts.js +5 -5
- package/dist/boilerplates/@batijs/solid/files/layouts/LayoutDefault.tsx +1 -1
- package/dist/boilerplates/@batijs/solid/files/pages/+config.ts +1 -1
- package/dist/boilerplates/@batijs/solid-sentry/files/$package.json.js +5 -5
- package/dist/boilerplates/@batijs/sqlite/files/$.env.js +3 -3
- package/dist/boilerplates/@batijs/sqlite/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/sqlite/files/$package.json.js +5 -17
- package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/schema/all.ts +0 -2
- package/dist/boilerplates/@batijs/sqlite/types/database/sqlite/schema/all.d.ts +0 -1
- package/dist/boilerplates/@batijs/tailwindcss/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/tailwindcss/files/$vite.config.ts.js +5 -5
- package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/telefunc/files/$vite.config.ts.js +5 -5
- package/dist/boilerplates/@batijs/trpc/files/$package.json.js +8 -8
- package/dist/boilerplates/@batijs/trpc/types/trpc/client.d.ts +3 -3
- package/dist/boilerplates/@batijs/trpc/types/trpc/server.d.ts +8 -8
- package/dist/boilerplates/@batijs/ts-rest/files/$package.json.js +7 -7
- package/dist/boilerplates/@batijs/vercel/files/$package.json.js +4 -4
- package/dist/boilerplates/@batijs/vercel/files/$tsconfig.json.js +3 -3
- package/dist/boilerplates/@batijs/vercel/files/$vite.config.ts.js +5 -5
- package/dist/boilerplates/@batijs/vercel/files/pages/$+config.ts.js +3 -3
- package/dist/boilerplates/@batijs/vue/files/$README.md.js +3 -3
- package/dist/boilerplates/@batijs/vue/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/vue/files/$tsconfig.json.js +3 -3
- package/dist/boilerplates/@batijs/vue/files/$vite.config.ts.js +6 -6
- package/dist/boilerplates/@batijs/vue/files/layouts/LayoutDefault.vue +1 -1
- package/dist/boilerplates/@batijs/vue/files/pages/+config.ts +1 -1
- package/dist/boilerplates/@batijs/vue-sentry/files/$package.json.js +5 -5
- package/dist/boilerplates/boilerplates.json +0 -59
- package/dist/{chunk-4WNEELKU.js → chunk-YO6CY4MA.js} +53461 -53354
- package/dist/index.js +63 -92
- package/package.json +6 -6
- package/dist/boilerplates/@batijs/d1-sqlite/files/database/d1/queries/lucia-auth.ts +0 -29
- package/dist/boilerplates/@batijs/d1-sqlite/files/database/migrations/lucia-auth.sql +0 -20
- package/dist/boilerplates/@batijs/d1-sqlite/types/database/d1/queries/lucia-auth.d.ts +0 -5
- package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/queries/lucia-auth.ts +0 -56
- package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/schema/lucia-auth.ts +0 -41
- package/dist/boilerplates/@batijs/drizzle/types/database/drizzle/queries/lucia-auth.d.ts +0 -25
- package/dist/boilerplates/@batijs/drizzle/types/database/drizzle/schema/lucia-auth.d.ts +0 -190
- package/dist/boilerplates/@batijs/lucia-auth/files/$.env.js +0 -32
- package/dist/boilerplates/@batijs/lucia-auth/files/$README.md.js +0 -38
- package/dist/boilerplates/@batijs/lucia-auth/files/$package.json.js +0 -113
- package/dist/boilerplates/@batijs/lucia-auth/files/global.d.ts +0 -11
- package/dist/boilerplates/@batijs/lucia-auth/files/lib/lucia-auth.ts +0 -136
- package/dist/boilerplates/@batijs/lucia-auth/files/pages/login/+guard.ts +0 -11
- package/dist/boilerplates/@batijs/lucia-auth/files/pages/login/style.css +0 -94
- package/dist/boilerplates/@batijs/lucia-auth/files/server/lucia-auth-handlers.ts +0 -401
- package/dist/boilerplates/@batijs/lucia-auth/types/lib/lucia-auth.d.ts +0 -63
- package/dist/boilerplates/@batijs/lucia-auth/types/pages/login/+guard.d.ts +0 -3
- package/dist/boilerplates/@batijs/lucia-auth/types/server/lucia-auth-handlers.d.ts +0 -65
- package/dist/boilerplates/@batijs/react-lucia-auth/files/pages/login/+Page.tsx +0 -97
- package/dist/boilerplates/@batijs/react-lucia-auth/types/pages/login/+Page.d.ts +0 -2
- package/dist/boilerplates/@batijs/solid-lucia-auth/files/pages/login/+Page.tsx +0 -97
- package/dist/boilerplates/@batijs/solid-lucia-auth/types/pages/login/+Page.d.ts +0 -2
- package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/queries/lucia-auth.ts +0 -27
- package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/schema/lucia-auth.ts +0 -32
- package/dist/boilerplates/@batijs/sqlite/types/database/sqlite/queries/lucia-auth.d.ts +0 -5
- package/dist/boilerplates/@batijs/sqlite/types/database/sqlite/schema/lucia-auth.d.ts +0 -1
- package/dist/boilerplates/@batijs/vue-lucia-auth/files/pages/login/+Page.vue +0 -88
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import "./style.css";
|
|
2
|
-
import { createSignal, untrack } from "solid-js";
|
|
3
|
-
import { navigate } from "vike/client/router";
|
|
4
|
-
|
|
5
|
-
type ValidationError = { username: string | null; password: string | null; invalid?: string };
|
|
6
|
-
|
|
7
|
-
export function Page() {
|
|
8
|
-
const [formData, setFormData] = createSignal({
|
|
9
|
-
username: "",
|
|
10
|
-
password: "",
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const [error, setError] = createSignal<ValidationError>({
|
|
14
|
-
username: null,
|
|
15
|
-
password: null,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const handleOnChange = (e: Event) => {
|
|
19
|
-
const { name, value } = e.currentTarget as HTMLInputElement;
|
|
20
|
-
setFormData((prev) => ({ ...prev, [name]: value }));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const handleOnSubmit = async (e: Event, action: "login" | "signup") => {
|
|
24
|
-
e.preventDefault();
|
|
25
|
-
try {
|
|
26
|
-
const response = await fetch(`/api/${action}`, {
|
|
27
|
-
method: "POST",
|
|
28
|
-
body: JSON.stringify(untrack(formData)),
|
|
29
|
-
headers: { "Content-Type": "application/json" },
|
|
30
|
-
});
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
const result: Record<string, any> = await response.json();
|
|
33
|
-
if ("error" in result) {
|
|
34
|
-
console.error("A validation error has occurred :", result.error);
|
|
35
|
-
setError(result.error);
|
|
36
|
-
} else {
|
|
37
|
-
await navigate("/");
|
|
38
|
-
}
|
|
39
|
-
} catch (err) {
|
|
40
|
-
console.error("An unknown error has occurred :", err);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
return (
|
|
44
|
-
<div class="form">
|
|
45
|
-
<div class="form-content">
|
|
46
|
-
<header>Login / Sign Up</header>
|
|
47
|
-
<form>
|
|
48
|
-
<div class="field">
|
|
49
|
-
<input
|
|
50
|
-
id="username"
|
|
51
|
-
type="text"
|
|
52
|
-
name="username"
|
|
53
|
-
value={formData().username}
|
|
54
|
-
onChange={handleOnChange}
|
|
55
|
-
placeholder="Username"
|
|
56
|
-
autocomplete="username"
|
|
57
|
-
/>
|
|
58
|
-
</div>
|
|
59
|
-
{error().username && <span class="field-error">{error().username}</span>}
|
|
60
|
-
|
|
61
|
-
<div class="field">
|
|
62
|
-
<input
|
|
63
|
-
id="password"
|
|
64
|
-
type="password"
|
|
65
|
-
name="password"
|
|
66
|
-
value={formData().password}
|
|
67
|
-
onChange={handleOnChange}
|
|
68
|
-
placeholder="Password"
|
|
69
|
-
/>
|
|
70
|
-
</div>
|
|
71
|
-
{error().password && <span class="field-error">{error().password}</span>}
|
|
72
|
-
{error().invalid && <span class="field-error">{error().invalid}</span>}
|
|
73
|
-
|
|
74
|
-
<div class="field button-group">
|
|
75
|
-
<button type="button" class="button-field signup-button" onClick={(e) => handleOnSubmit(e, "signup")}>
|
|
76
|
-
Sign Up
|
|
77
|
-
</button>
|
|
78
|
-
<button type="submit" class="button-field login-button" onClick={(e) => handleOnSubmit(e, "login")}>
|
|
79
|
-
Login
|
|
80
|
-
</button>
|
|
81
|
-
</div>
|
|
82
|
-
</form>
|
|
83
|
-
</div>
|
|
84
|
-
|
|
85
|
-
<div class="media-options">
|
|
86
|
-
<a href="/api/login/github" class="field github">
|
|
87
|
-
<img
|
|
88
|
-
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA0OTYgNTEyJz48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0nTTE2NS45IDM5Ny40YzAgMi0yLjMgMy42LTUuMiAzLjYtMy4zIC4zLTUuNi0xLjMtNS42LTMuNiAwLTIgMi4zLTMuNiA1LjItMy42IDMtLjMgNS42IDEuMyA1LjYgMy42em0tMzEuMS00LjVjLS43IDIgMS4zIDQuMyA0LjMgNC45IDIuNiAxIDUuNiAwIDYuMi0ycy0xLjMtNC4zLTQuMy01LjJjLTIuNi0uNy01LjUgL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EgMS0zLjMtLjctNS4yLTEuNi0xLjYtMy45LTIuMy01LjItMXptLTEwLjgtOC4xYy0uNyAxLjMgLjMgMi45IDIuMyAzLjkgMS42IDEgMy42IC43IDQuMy0uNyAuNy0xLjMtLjMtMi45LTIuMy0zLjktMi0uNi0zLjYtLjMtNC4zIC43em0zMi40IDM1LjZjLTEuNiAxLjMtMSA0LjMgMS4zIDYuMiAyLjMgMi4zIDUuMiAyLjYgNi41IDEgMS4zLTEuMyAuNy00LjMtMS4zLTYuMi0yLjItMi4zLTUuMi0yLjYtNi41LTF6bS0xMS40LTE0LjdjLTEuNiAxLTEuNiAzLjYgMCA1LjkgMS42IDIuMyA0LjMgMy4zIDUuNiAyLjMgMS42LTEuMyAxLjYtMy45IDAtNi4yLTEuNC0yLjMtNC0zLjMtNS42LTJ6Jy8+PC9zdmc+"
|
|
89
|
-
class="github-icon"
|
|
90
|
-
alt=""
|
|
91
|
-
/>
|
|
92
|
-
<span>Login with Github</span>
|
|
93
|
-
</a>
|
|
94
|
-
</div>
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*# BATI include-if-imported #*/
|
|
2
|
-
import type { Database, Transaction } from "better-sqlite3";
|
|
3
|
-
|
|
4
|
-
export function getExistingUser<T>(db: Database, username: string) {
|
|
5
|
-
return db.prepare<[string], T>("SELECT * FROM users WHERE username = ?").get(username);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function getExistingAccount<T>(db: Database, providerId: string, providerUserId: number) {
|
|
9
|
-
return db
|
|
10
|
-
.prepare<[string, number], T>("SELECT * FROM oauth_accounts WHERE provider_id = ? AND provider_user_id = ?")
|
|
11
|
-
.get(providerId, providerUserId);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function signupWithGithub(db: Database, userId: string, username: string, githubUserId: number): Transaction {
|
|
15
|
-
return db.transaction(() => {
|
|
16
|
-
db.prepare("INSERT INTO users (id, username) VALUES (?, ?)").run(userId, username);
|
|
17
|
-
db.prepare("INSERT INTO oauth_accounts (provider_id, provider_user_id, user_id) VALUES (?, ?, ?)").run(
|
|
18
|
-
"github",
|
|
19
|
-
githubUserId,
|
|
20
|
-
userId,
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function signupWithCredentials(db: Database, userId: string, username: string, passwordHash: string) {
|
|
26
|
-
return db.prepare("INSERT INTO users (id, username, password) VALUES(?, ?, ?)").run(userId, username, passwordHash);
|
|
27
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*{ @if (it.BATI.has("lucia-auth")) }*/
|
|
2
|
-
import "dotenv/config";
|
|
3
|
-
import { db } from "../db";
|
|
4
|
-
|
|
5
|
-
const client = db();
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* SQLite Schema
|
|
9
|
-
*
|
|
10
|
-
* @link {@see https://lucia-auth.com/database/sqlite#schema}
|
|
11
|
-
*/
|
|
12
|
-
client.exec(`CREATE TABLE IF NOT EXISTS users (
|
|
13
|
-
id TEXT NOT NULL PRIMARY KEY,
|
|
14
|
-
username TEXT NOT NULL UNIQUE,
|
|
15
|
-
password TEXT
|
|
16
|
-
)`);
|
|
17
|
-
|
|
18
|
-
client.exec(`CREATE TABLE IF NOT EXISTS oauth_accounts (
|
|
19
|
-
provider_id TEXT NOT NULL,
|
|
20
|
-
provider_user_id INTEGER NOT NULL,
|
|
21
|
-
user_id TEXT NOT NULL,
|
|
22
|
-
PRIMARY KEY (provider_id, provider_user_id),
|
|
23
|
-
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE cascade ON DELETE cascade
|
|
24
|
-
)`);
|
|
25
|
-
|
|
26
|
-
client.exec(`CREATE TABLE IF NOT EXISTS sessions (
|
|
27
|
-
id TEXT NOT NULL PRIMARY KEY,
|
|
28
|
-
expires_at INTEGER NOT NULL,
|
|
29
|
-
user_id TEXT NOT NULL,
|
|
30
|
-
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE cascade ON DELETE cascade
|
|
31
|
-
)`);
|
|
32
|
-
/*{ /if }*/
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Database, Transaction } from "better-sqlite3";
|
|
2
|
-
export declare function getExistingUser<T>(db: Database, username: string): T | undefined;
|
|
3
|
-
export declare function getExistingAccount<T>(db: Database, providerId: string, providerUserId: number): T | undefined;
|
|
4
|
-
export declare function signupWithGithub(db: Database, userId: string, username: string, githubUserId: number): Transaction;
|
|
5
|
-
export declare function signupWithCredentials(db: Database, userId: string, username: string, passwordHash: string): import("better-sqlite3").RunResult;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="form">
|
|
3
|
-
<div class="form-content">
|
|
4
|
-
<header>Login / Sign Up</header>
|
|
5
|
-
<form>
|
|
6
|
-
<div class="field">
|
|
7
|
-
<input
|
|
8
|
-
id="username"
|
|
9
|
-
v-model="formData.username"
|
|
10
|
-
type="text"
|
|
11
|
-
name="username"
|
|
12
|
-
placeholder="Username"
|
|
13
|
-
autocomplete="username"
|
|
14
|
-
/>
|
|
15
|
-
</div>
|
|
16
|
-
<span v-if="error.username" class="field-error">{{ error.username }}</span>
|
|
17
|
-
|
|
18
|
-
<div class="field">
|
|
19
|
-
<input id="password" v-model="formData.password" type="password" name="password" placeholder="Password" />
|
|
20
|
-
</div>
|
|
21
|
-
<span v-if="error.password" class="field-error">{{ error.password }}</span>
|
|
22
|
-
<span v-if="error.invalid" class="field-error">{{ error.invalid }}</span>
|
|
23
|
-
|
|
24
|
-
<div class="field button-group">
|
|
25
|
-
<button type="button" class="button-field signup-button" @click.prevent="handleOnSubmit('signup')">
|
|
26
|
-
Sign Up
|
|
27
|
-
</button>
|
|
28
|
-
<button type="submit" class="button-field login-button" @click.prevent="handleOnSubmit('login')">
|
|
29
|
-
Login
|
|
30
|
-
</button>
|
|
31
|
-
</div>
|
|
32
|
-
</form>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<div class="media-options">
|
|
36
|
-
<a href="/api/login/github" class="field github">
|
|
37
|
-
<img
|
|
38
|
-
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA0OTYgNTEyJz48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0nTTE2NS45IDM5Ny40YzAgMi0yLjMgMy42LTUuMiAzLjYtMy4zIC4zLTUuNi0xLjMtNS42LTMuNiAwLTIgMi4zLTMuNiA1LjItMy42IDMtLjMgNS42IDEuMyA1LjYgMy42em0tMzEuMS00LjVjLS43IDIgMS4zIDQuMyA0LjMgNC45IDIuNiAxIDUuNiAwIDYuMi0ycy0xLjMtNC4zLTQuMy01LjJjLTIuNi0uNy01LjUgLjMtNi4yIDIuM3ptNDQuMi0xLjdjLTIuOSAuNy00LjkgMi42LTQuNiA0LjkgLjMgMiAyLjkgMy4zIDUuOSAyLjYgMi45LS43IDQuOS0yLjYgNC42LTQuNi0uMy0xLjktMy0zLjItNS45LTIuOXpNMjQ0LjggOEMxMDYuMSA4IDAgMTEzLjMgMCAyNTJjMCAxMTAuOSA2OS44IDIwNS44IDE2OS41IDIzOS4yIDEyLjggMi4zIDE3LjMtNS42IDE3LjMtMTIuMSAwLTYuMi0uMy00MC40LS4zLTYxLjQgMCAwLTcwIDE1LTg0LjctMjkuOCAwIDAtMTEuNC0yOS4xLTI3LjgtMzYuNiAwIDAtMjIuOS0xNS43IDEuNi0xNS40IDAgMCAyNC45IDI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YtMy45IDAtNi4yLTEuNC0yLjMtNC0zLjMtNS42LTJ6Jy8+PC9zdmc+"
|
|
39
|
-
class="github-icon"
|
|
40
|
-
alt=""
|
|
41
|
-
/>
|
|
42
|
-
<span>Login with Github</span>
|
|
43
|
-
</a>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</template>
|
|
47
|
-
|
|
48
|
-
<script lang="ts" setup>
|
|
49
|
-
import "./style.css";
|
|
50
|
-
import { navigate } from "vike/client/router";
|
|
51
|
-
import { ref } from "vue";
|
|
52
|
-
|
|
53
|
-
type ValidationError = {
|
|
54
|
-
username: string | null;
|
|
55
|
-
password: string | null;
|
|
56
|
-
invalid?: string;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const formData = ref({
|
|
60
|
-
username: "",
|
|
61
|
-
password: "",
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
let error = ref<ValidationError>({
|
|
65
|
-
username: null,
|
|
66
|
-
password: null,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
async function handleOnSubmit(action: "login" | "signup") {
|
|
70
|
-
try {
|
|
71
|
-
const response = await fetch(`/api/${action}`, {
|
|
72
|
-
method: "POST",
|
|
73
|
-
body: JSON.stringify(formData.value),
|
|
74
|
-
headers: { "Content-Type": "application/json" },
|
|
75
|
-
});
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
-
const result: Record<string, any> = await response.json();
|
|
78
|
-
if ("error" in result) {
|
|
79
|
-
console.error("A validation error has occurred :", result.error);
|
|
80
|
-
error.value = { ...result.error };
|
|
81
|
-
} else {
|
|
82
|
-
await navigate("/");
|
|
83
|
-
}
|
|
84
|
-
} catch (err) {
|
|
85
|
-
console.error("An unknown error has occurred :", err);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
</script>
|