Store password reset requests in database
#610
Samengevoegd
rfwatson
heeft 4 commits samengevoegd van feature/persist_password_reset
naar master
5 jaren geleden
Laden…
Verwijs in nieuw issue
Er is nog geen inhoud.
Verwijder branch 'feature/persist_password_reset'
Het verwijderen van een branch is permanent. Het KAN NIET ongedaan gemaakt worden. Wil je toch doorgaan?
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! 😊
Reviewers
4b205fa995
.Stap 1:
Vanuit het project, check een branch uit en test de veranderingen.Stap 2:
Voeg de wijzigingen samen en update ze op Forgejo.