Store password reset requests in database
#610
Zusammengeführt
rfwatson
hat 4 Commits von feature/persist_password_reset
nach master
vor 5 Jahren zusammengeführt
Laden…
In neuem Issue referenzieren
Hier gibt es bis jetzt noch keinen Inhalt.
Branch „feature/persist_password_reset“ löschen
Das Löschen eines Branches ist permanent. Es KANN NICHT rückgängig gemacht werden. Fortfahren?
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! 😊
Reviewer
4b205fa995
gemergt.Schritt 1:
Wechsle auf einen neuen Branch in deinem lokalen Repository und teste die Änderungen.Schritt 2:
Führe die Änderungen zusammen und aktualisiere den Stand online auf Forgejo.