Store password reset requests in database #610
No reviewers
Labels
No labels
A: API
A: Backend
A: Federation
A: Front-End
A: I18N
A: Meta
A: Security
Build
C: Bug
C: Discussion
C: Enhancement
C: Feature
Compatibility
Dependency
Design
Documentation
Good first issue
Help welcome
Mobile
Rendering
S: Blocked
S: Duplicate
S: Incomplete
S: Instance specific
S: Invalid
S: Needs Voting/Discussion
S: Ready for review
Suggestion
S: Voted on Loomio
S: Wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Plume/Plume#610
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feature/persist_password_reset"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Had a go at closing #600.
New to lots of stuff here (Rust, Diesel, Rocket, Plume...) so all feedback appreciated.
TODO
@ -243,4 +223,4 @@
form: Form<NewPasswordForm>,
rockets: PlumeRocket,
) -> Result<Flash<Redirect>, Ructe> {
form.validate()
The logic to detect an expired token is private to the model now. Not sure how important having a specific error is. We could maybe return a custom Diesel error?
It would be good to test that old password reset requests are ignored.
The simplest way I can think of would be to insert a record, and then update its
creation_date
with some raw SQL in the test. It feels pretty dirty though. Better ideas appreciated.What you did so far looks great! Thank you for helping with that.
thread::sleep(2 * 60 * 60 * 1000)
More seriously, I think you can pass tuples to
diesel::insert_into(...).values()
, like:You can probably use it instead of
PasswordResetRequest::insert
in this test.@ -243,4 +223,4 @@
form: Form<NewPasswordForm>,
rockets: PlumeRocket,
) -> Result<Flash<Redirect>, Ructe> {
form.validate()
Maybe, instead of mapping the error to
to_validation
, you could have a closure that returns the specific error that was previously returned?Codecov Report
@ -243,4 +223,4 @@
form: Form<NewPasswordForm>,
rockets: PlumeRocket,
) -> Result<Flash<Redirect>, Ructe> {
form.validate()
I ended up adding a new
Expired
error variant - it felt generic enough to be useful elsewhere in the app too. Happy to iterate on this more if it doesn't feel like a good approach though.Pretty happy with this now. Still a couple of CI failures but they look random to me
Yes the CI fails sometimes because it doesn't have enough memory to build…
Everything seems to work fine. Thank you! 😊