-
Notifications
You must be signed in to change notification settings - Fork 1
Fix typescript - #13
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
Fix typescript - #13
Changes from all commits
df78c35
8fe361c
5ac2945
8482366
7b0aa8e
f992b87
d6a2709
22bd7a6
59be9bd
4bcbfef
de1c8a4
4ba3c07
0fa593b
ca64821
0f80499
e8822b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { Entity, Model, Prop, Index } from "@/_lib/mongoose"; | ||
| import { User } from "@/user/user.entity"; | ||
|
|
||
| @Entity({ timestamps: true }) | ||
| @Index({ tokenHash: 1 }, { unique: true }) | ||
| export class PasswordReset extends Model { | ||
|
|
||
| id: string; | ||
|
|
||
| @Prop({ type: String, required: true }) | ||
| tokenHash: string; | ||
|
|
||
| @Prop({ type: Date, required: true, expires: 0 }) | ||
| expiresAt: Date; | ||
|
|
||
| @Prop({ type: Boolean, default: false }) | ||
| used: boolean; | ||
|
|
||
| @Prop({ type: User, required: true }) | ||
| user: User; | ||
| } |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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.
The reset flow updates the user with
updateUser(...), which usesfindByIdAndUpdate; Mongoose setters (like the bcrypt hash setter onUser.password) are not applied to update queries by default. That means reset passwords get stored in plaintext, andbcrypt.compareduring login will fail or throw because it expects a hash. Users who reset their password won’t be able to sign in, and you end up storing raw passwords. Consider hashing explicitly or switching to afindById+savepath (or enablerunSettersOnQuery) for this update.Useful? React with 👍 / 👎.