From b4b845f5b8f81952c9c68c8570c3fede68c0eff9 Mon Sep 17 00:00:00 2001 From: Atridad Lahiji <88056492+atridadl@users.noreply.github.com> Date: Tue, 30 May 2023 22:16:33 -0600 Subject: [PATCH 1/2] Auth flow for signin and signout now preserves the path sent --- src/components/Navbar.tsx | 4 +++- src/pages/profile/index.tsx | 2 +- src/pages/room/[id].tsx | 2 +- src/server/auth.ts | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 5de9201..e36eefb 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -68,7 +68,9 @@ const Navbar: React.FC = ({ title }) => { )}
  • - void signOut()}>Sign Out + void signOut({ callbackUrl: "/" })}> + Sign Out +
  • diff --git a/src/pages/profile/index.tsx b/src/pages/profile/index.tsx index 4b0947a..69b87c6 100644 --- a/src/pages/profile/index.tsx +++ b/src/pages/profile/index.tsx @@ -18,7 +18,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { if (!session) { return { redirect: { - destination: "/", + destination: `/api/auth/signin?callbackUrl=${ctx.resolvedUrl}`, permanent: false, }, }; diff --git a/src/pages/room/[id].tsx b/src/pages/room/[id].tsx index 401e339..8ee5f1c 100644 --- a/src/pages/room/[id].tsx +++ b/src/pages/room/[id].tsx @@ -37,7 +37,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { if (!session) { return { redirect: { - destination: "/", + destination: `/api/auth/signin?callbackUrl=${ctx.resolvedUrl}`, permanent: false, }, }; diff --git a/src/server/auth.ts b/src/server/auth.ts index 4422904..c00249e 100644 --- a/src/server/auth.ts +++ b/src/server/auth.ts @@ -12,6 +12,7 @@ import { prisma } from "~/server/db"; import type { Role } from "~/utils/types"; import { sendMail } from "fms-ts"; import { cacheClient, deleteFromCache } from "redicache-ts"; +import { redirect } from "next/navigation"; const client = cacheClient(env.REDIS_URL); @@ -75,7 +76,7 @@ export const authOptions: NextAuthOptions = { async signIn({}) { await deleteFromCache(client, env.APP_ENV, `kv_userlist_admin`); }, - async signOut({}) { + async signOut() { await deleteFromCache(client, env.APP_ENV, `kv_userlist_admin`); }, }, From d69d25dc5b83bd88125f4f1957847c97032c39a5 Mon Sep 17 00:00:00 2001 From: Atridad Lahiji <88056492+atridadl@users.noreply.github.com> Date: Tue, 30 May 2023 22:17:06 -0600 Subject: [PATCH 2/2] Bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9503d84..fe798e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sprintpadawan", - "version": "1.0.5", + "version": "1.0.6", "description": "Plan. Sprint. Repeat.", "private": true, "scripts": {