server/utils/auth.ts

14 lines
267 B
TypeScript
Raw Normal View History

2023-09-13 21:02:16 +02:00
import { Token } from "~database/entities/Token";
export const getUserByToken = async (access_token: string | null) => {
if (!access_token) return null;
const token = await Token.findOneBy({
access_token,
});
if (!token) return null;
return token.user;
};