Skip to content

Commit d55686e

Browse files
committed
fomrat
1 parent 7d4100d commit d55686e

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

app/lib/auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import { betterAuth } from "better-auth";
22
import { drizzleAdapter } from "better-auth/adapters/drizzle";
33
import { anonymous } from "better-auth/plugins";
44
import { eq } from "drizzle-orm";
5+
import * as schema from "../lib/db/schema";
56
import { getDB } from "./db";
67

78
export function getAuth(env?: Env) {
89
const auth = betterAuth({
910
database: drizzleAdapter(getDB(env), {
1011
provider: "pg",
12+
schema: schema,
1113
}),
1214
emailAndPassword: {
1315
enabled: true,

app/routes/_index.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { drizzle as drizzleNeon } from "drizzle-orm/neon-http";
22
import { drizzle as drizzlePg } from "drizzle-orm/node-postgres";
3-
import { Link } from "react-router";
3+
import type { c } from "node_modules/better-auth/dist/shared/better-auth.C9FmyZ5W.cjs";
4+
import { Link, useNavigate } from "react-router";
5+
import { authClient } from "~/lib/auth-client";
46
import { getRedisClient } from "~/lib/redis";
57
import type { Route } from "./+types/_index";
68

@@ -19,16 +21,25 @@ export async function loader({ context }: Route.LoaderArgs) {
1921
}
2022

2123
export default function Page() {
24+
const navigate = useNavigate();
25+
const anonymousLoginAndStart = async () => {
26+
const _user = await authClient.signIn.anonymous();
27+
navigate("/play");
28+
};
2229
return (
2330
<>
2431
<h1 className="text-5xl text-center pb-1">Hitori Mahjong</h1>
25-
<Link to="/start">
26-
<p className="text-center link">Get Started</p>
27-
</Link>
28-
29-
<Link to="/learn">
30-
<p className="text-center link">Learn How to Play</p>
31-
</Link>
32+
<div className="flex justify-center items-center flex-col gap-4 py-4">
33+
<button onClick={anonymousLoginAndStart} className="link" type="button">
34+
Play as Guest
35+
</button>
36+
<Link to="/login" className="link">
37+
Login
38+
</Link>
39+
<Link to="/learn" className="link">
40+
Learn How to Play
41+
</Link>
42+
</div>
3243
</>
3344
);
3445
}

app/routes/login.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function Page() {
2+
return (
3+
<>
4+
<p>Log in</p>
5+
</>
6+
);
7+
}

app/routes/play.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function Page() {
2+
return (
3+
<>
4+
<p>Play Page</p>
5+
</>
6+
);
7+
}

0 commit comments

Comments
 (0)