-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TM-1677] Implement user verification BE #56
base: staging
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 8a9a0d8.
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
token: string | null; | ||
|
||
@Column(BIGINT.UNSIGNED) | ||
userId: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This userId should get a foreign key and this entity should get a relationship to user:
@ForeignKey(() => User)
@Column(BIGINT.UNSIGNED)
userId: number;
@BelongsTo(() => User)
user: User | null;
}); | ||
if (user == null) { | ||
throw new NotFoundException("User not found"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the BelongsTo change requested on the verification entity, this can be a single DB query:
const verification = await Verification.findOne({
where: { token }
include: [{ association: "user", attributes: ["id", "uuid", "emailAddressVerifiedAt"]
});
if (verification?.user == null) throw new NotFoundException("Verification token invalid");
And then use verification.user
below instead of user
.
Pull request checklist
Please check if your PR fulfills the following requirements:
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this introduce a breaking change?
Other information