Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
feat(user-detail): clean guardian info
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAndersen committed Oct 15, 2024
1 parent 9c7ce8a commit 3dd0b5d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/collections/user-detail/hooks/user-detail-update.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ export class UserDetailUpdateHook extends Hook {
.join("");
};

private cleanGuardianInfo(
guardian: UserDetail["guardian"],
): UserDetail["guardian"] {
return (
guardian && {
...guardian,
name: this.cleanUserInput(guardian.name),
email: guardian.email.toLowerCase(),
}
);
}

public override async before(
body: unknown,
accessToken: AccessToken,
Expand Down Expand Up @@ -51,7 +63,9 @@ export class UserDetailUpdateHook extends Hook {
...(postCode !== undefined && { postCode }),
...(phone !== undefined && { phone }),
...(emailConfirmed !== undefined && { emailConfirmed }),
...(guardian !== undefined && { guardian }),
...(guardian !== undefined && {
guardian: this.cleanGuardianInfo(guardian) ?? guardian,
}),
};
}
}
Expand Down

0 comments on commit 3dd0b5d

Please sign in to comment.