fix: userId migration (#2453)

This commit is contained in:
Anshuman Pandey
2024-04-19 18:23:41 +05:30
committed by GitHub
parent c6f9a6cdfc
commit e48ddbad5d
3 changed files with 29 additions and 33 deletions
@@ -31,6 +31,9 @@ export async function POST(req: Request, context: Context): Promise<Response> {
);
}
// remove userId from attributes because it is not allowed to be updated
const { userId: userIdAttr, ...updatedAttributes } = inputValidation.data.attributes;
let person = await getPersonByUserId(environmentId, userId);
if (!person) {
@@ -40,11 +43,10 @@ export async function POST(req: Request, context: Context): Promise<Response> {
}
// Check if the person is already up to date
const updatedAtttributes = inputValidation.data.attributes;
const oldAttributes = person.attributes;
let isUpToDate = true;
for (const key in updatedAtttributes) {
if (updatedAtttributes[key] !== oldAttributes[key]) {
for (const key in updatedAttributes) {
if (updatedAttributes[key] !== oldAttributes[key]) {
isUpToDate = false;
break;
}