fix: Types on overridden findByPk methods (#5908)

This commit is contained in:
Tom Moor
2023-10-01 15:02:56 -04:00
committed by GitHub
parent e2a6d828a9
commit 41a6f77998
6 changed files with 59 additions and 16 deletions

View File

@@ -1,5 +1,4 @@
import { subMinutes } from "date-fns";
import invariant from "invariant";
import JWT from "jsonwebtoken";
import { Team, User } from "@server/models";
import { AuthenticationError } from "../errors";
@@ -85,8 +84,9 @@ export async function getUserForEmailSigninToken(token: string): Promise<User> {
}
}
const user = await User.scope("withTeam").findByPk(payload.id);
invariant(user, "User not found");
const user = await User.scope("withTeam").findByPk(payload.id, {
rejectOnEmpty: true,
});
try {
JWT.verify(token, user.jwtSecret);