Auth flow for signin and signout now preserves the path sent
This commit is contained in:
parent
d57079030f
commit
b4b845f5b8
4 changed files with 7 additions and 4 deletions
|
@ -68,7 +68,9 @@ const Navbar: React.FC<NavbarProps> = ({ title }) => {
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
<li>
|
<li>
|
||||||
<a onClick={() => void signOut()}>Sign Out</a>
|
<a onClick={() => void signOut({ callbackUrl: "/" })}>
|
||||||
|
Sign Out
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
destination: "/",
|
destination: `/api/auth/signin?callbackUrl=${ctx.resolvedUrl}`,
|
||||||
permanent: false,
|
permanent: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
destination: "/",
|
destination: `/api/auth/signin?callbackUrl=${ctx.resolvedUrl}`,
|
||||||
permanent: false,
|
permanent: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { prisma } from "~/server/db";
|
||||||
import type { Role } from "~/utils/types";
|
import type { Role } from "~/utils/types";
|
||||||
import { sendMail } from "fms-ts";
|
import { sendMail } from "fms-ts";
|
||||||
import { cacheClient, deleteFromCache } from "redicache-ts";
|
import { cacheClient, deleteFromCache } from "redicache-ts";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
const client = cacheClient(env.REDIS_URL);
|
const client = cacheClient(env.REDIS_URL);
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ export const authOptions: NextAuthOptions = {
|
||||||
async signIn({}) {
|
async signIn({}) {
|
||||||
await deleteFromCache(client, env.APP_ENV, `kv_userlist_admin`);
|
await deleteFromCache(client, env.APP_ENV, `kv_userlist_admin`);
|
||||||
},
|
},
|
||||||
async signOut({}) {
|
async signOut() {
|
||||||
await deleteFromCache(client, env.APP_ENV, `kv_userlist_admin`);
|
await deleteFromCache(client, env.APP_ENV, `kv_userlist_admin`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue