Skip to content

Commit 3928dcd

Browse files
authored
chore: store provider access token (#52)
1 parent 59b4987 commit 3928dcd

File tree

18 files changed

+551
-89
lines changed

18 files changed

+551
-89
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"better-auth": "1.4.0-beta.21",
2323
"class-variance-authority": "0.7.1",
2424
"clsx": "2.1.1",
25+
"jose": "^6.1.2",
2526
"next": "16.0.3",
2627
"react": "19.2.0",
2728
"react-dom": "19.2.0",
@@ -49,6 +50,7 @@
4950
"tailwindcss": "^4",
5051
"tsx": "4.20.6",
5152
"typescript": "^5",
53+
"vite": "^7.2.2",
5254
"vite-tsconfig-paths": "^5.1.4",
5355
"vitest": "^4.0.8"
5456
},

pnpm-lock.yaml

Lines changed: 17 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render, screen } from "@testing-library/react";
22
import { beforeEach, expect, test, vi } from "vitest";
3-
import Home from "../src/app/page";
3+
import Home from "../page";
44

55
// Mock Next.js modules
66
vi.mock("next/headers", () => ({
@@ -12,7 +12,7 @@ vi.mock("next/navigation", () => ({
1212
}));
1313

1414
// Mock auth module
15-
vi.mock("@/lib/auth", () => ({
15+
vi.mock("@/lib/auth/auth", () => ({
1616
auth: {
1717
api: {
1818
getSession: vi.fn(() =>

src/app/api/auth/[...all]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { toNextJsHandler } from "better-auth/next-js";
2-
import { auth } from "@/lib/auth";
2+
import { auth } from "@/lib/auth/auth";
33

44
export const { GET, POST } = toNextJsHandler(auth.handler);

src/app/catalog/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { headers } from "next/headers";
22
import { redirect } from "next/navigation";
33
import { SignOut } from "@/components/sign-out-button";
4-
import { auth } from "@/lib/auth";
4+
import { auth } from "@/lib/auth/auth";
55

66
export default async function CatalogPage() {
77
const session = await auth.api.getSession({

src/app/catalogue/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useRouter } from "next/navigation";
44
import { useEffect, useState } from "react";
55
import { toast } from "sonner";
6-
import { signOut, useSession } from "@/lib/auth-client";
6+
import { signOut, useSession } from "@/lib/auth/auth-client";
77

88
export default function CataloguePage() {
99
const router = useRouter();

src/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { headers } from "next/headers";
22
import Link from "next/link";
33
import { redirect } from "next/navigation";
4-
import { auth } from "@/lib/auth";
4+
import { auth } from "@/lib/auth/auth";
55

66
export default async function Home() {
77
const session = await auth.api.getSession({
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ vi.mock("sonner", () => ({
1717
}));
1818

1919
// Mock auth client
20-
vi.mock("@/lib/auth-client", () => ({
20+
vi.mock("@/lib/auth/auth-client", () => ({
2121
authClient: {
2222
signIn: {
2323
oauth2: vi.fn(),
@@ -64,7 +64,7 @@ describe("SignInPage", () => {
6464

6565
test("calls authClient.signIn.oauth2 when button is clicked", async () => {
6666
const user = userEvent.setup();
67-
const { authClient } = await import("@/lib/auth-client");
67+
const { authClient } = await import("@/lib/auth/auth-client");
6868
vi.mocked(authClient.signIn.oauth2).mockResolvedValue({ error: null });
6969

7070
render(<SignInPage />);
@@ -83,7 +83,7 @@ describe("SignInPage", () => {
8383
test("shows error toast when signin fails with error", async () => {
8484
const user = userEvent.setup();
8585
const { toast } = await import("sonner");
86-
const { authClient } = await import("@/lib/auth-client");
86+
const { authClient } = await import("@/lib/auth/auth-client");
8787

8888
vi.mocked(authClient.signIn.oauth2).mockResolvedValue({
8989
error: {
@@ -106,7 +106,7 @@ describe("SignInPage", () => {
106106
test("shows error toast when signin throws exception", async () => {
107107
const user = userEvent.setup();
108108
const { toast } = await import("sonner");
109-
const { authClient } = await import("@/lib/auth-client");
109+
const { authClient } = await import("@/lib/auth/auth-client");
110110

111111
vi.mocked(authClient.signIn.oauth2).mockRejectedValue(
112112
new Error("Network error"),
@@ -127,7 +127,7 @@ describe("SignInPage", () => {
127127
test("shows generic error message for unknown errors", async () => {
128128
const user = userEvent.setup();
129129
const { toast } = await import("sonner");
130-
const { authClient } = await import("@/lib/auth-client");
130+
const { authClient } = await import("@/lib/auth/auth-client");
131131

132132
vi.mocked(authClient.signIn.oauth2).mockRejectedValue(
133133
"Something went wrong",

src/app/signin/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import Image from "next/image";
44
import { toast } from "sonner";
55
import { Button } from "@/components/ui/button";
6-
import { authClient } from "@/lib/auth-client";
6+
import { authClient } from "@/lib/auth/auth-client";
77

88
const OIDC_PROVIDER_ID = process.env.NEXT_PUBLIC_OIDC_PROVIDER_ID || "oidc";
99

src/components/sign-out-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useState } from "react";
44
import { toast } from "sonner";
55
import { Button } from "@/components/ui/button";
6-
import { signOut } from "@/lib/auth-client";
6+
import { signOut } from "@/lib/auth/auth-client";
77

88
export function SignOut() {
99
const [isSigningOut, setIsSigningOut] = useState(false);

0 commit comments

Comments
 (0)