fix: resolve issues with signing document stickiness

This commit is contained in:
Mythie
2023-09-28 17:32:31 +10:00
parent adf1359527
commit 5cba913c55
20 changed files with 73 additions and 42 deletions

View File

@ -15,7 +15,7 @@ export const getServerSession = async ({ req, res }: GetServerSessionOptions) =>
const session = await getNextAuthServerSession(req, res, NEXT_AUTH_OPTIONS);
if (!session || !session.user?.email) {
return null;
return { user: null, session: null };
}
const user = await prisma.user.findFirstOrThrow({
@ -24,14 +24,14 @@ export const getServerSession = async ({ req, res }: GetServerSessionOptions) =>
},
});
return user;
return { user, session };
};
export const getServerComponentSession = async () => {
const session = await getNextAuthServerSession(NEXT_AUTH_OPTIONS);
if (!session || !session.user?.email) {
return null;
return { user: null, session: null };
}
const user = await prisma.user.findFirstOrThrow({
@ -40,15 +40,15 @@ export const getServerComponentSession = async () => {
},
});
return user;
return { user, session };
};
export const getRequiredServerComponentSession = async () => {
const session = await getServerComponentSession();
const { user, session } = await getServerComponentSession();
if (!session) {
if (!user || !session) {
throw new Error('No session found');
}
return session;
return { user, session };
};

View File

@ -17,7 +17,7 @@ import { alphaid } from '../id';
export const getPresignPostUrl = async (fileName: string, contentType: string) => {
const client = getS3Client();
const user = await getServerComponentSession();
const { user } = await getServerComponentSession();
// Get the basename and extension for the file
const { name, ext } = path.parse(fileName);