fix: Allow soft deletion of teams (#1754)

* fix: Allow soft deletion of teams

* test: regression specs
This commit is contained in:
Tom Moor
2020-12-30 09:40:23 -08:00
committed by GitHub
parent 8dba32b5e0
commit ba61091c4c
7 changed files with 137 additions and 33 deletions

View File

@ -2,7 +2,7 @@
import subMinutes from "date-fns/sub_minutes";
import JWT from "jsonwebtoken";
import { AuthenticationError } from "../errors";
import { User } from "../models";
import { Team, User } from "../models";
function getJWTPayload(token) {
let payload;
@ -28,7 +28,15 @@ export async function getUserForJWT(token: string): Promise<User> {
}
}
const user = await User.findByPk(payload.id);
const user = await User.findByPk(payload.id, {
include: [
{
model: Team,
as: "team",
required: true,
},
],
});
if (payload.type === "transfer") {
// If the user has made a single API request since the transfer token was