mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
feat: add authorization for api calls
This commit is contained in:
15
packages/lib/server-only/public-api/get-user-by-token.ts
Normal file
15
packages/lib/server-only/public-api/get-user-by-token.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
export const checkUserFromToken = async ({ token }: { token: string }) => {
|
||||
const user = await prisma.user.findFirstOrThrow({
|
||||
where: {
|
||||
ApiToken: {
|
||||
some: {
|
||||
token: token,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return user;
|
||||
};
|
||||
Reference in New Issue
Block a user