Store password reset requests in database #610

Birleştirildi
rfwatson 2019-06-04 18:55:18 +00:00 feature/persist_password_reset içindeki 4 işlemeyi master ile birleştirdi
rfwatson 2019-06-02 13:59:38 +00:00 yorum yaptı (github.com konumundan göç edildi)

Had a go at closing #600.

New to lots of stuff here (Rust, Diesel, Rocket, Plume...) so all feedback appreciated.

TODO

  • SQLite migrations
  • resolve inline TODOs
  • integration tests?
  • fix CI issues
Had a go at closing #600. New to lots of stuff here (Rust, Diesel, Rocket, Plume...) so all feedback appreciated. ## TODO * [x] SQLite migrations * [x] resolve inline TODOs * [ ] integration tests? * [x] fix CI issues
rfwatson (github.com konumundan göç edildi) 2019-06-02 14:01:14 +00:00 incelendi
@ -243,4 +223,4 @@
form: Form<NewPasswordForm>,
rockets: PlumeRocket,
) -> Result<Flash<Redirect>, Ructe> {
form.validate()
rfwatson (github.com konumundan göç edildi) 2019-06-02 14:01:14 +00:00 yorum yaptı

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?

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?
rfwatson (github.com konumundan göç edildi) 2019-06-02 14:10:29 +00:00 incelendi
rfwatson (github.com konumundan göç edildi) 2019-06-02 14:10:29 +00:00 yorum yaptı

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.

It would be good to test that old password reset requests are [ignored](https://github.com/Plume-org/Plume/pull/610/files#diff-a248869f1983a92462c39c8b2ea8a66eR44). 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.
elegaanz (github.com konumundan göç edildi) 2019-06-02 16:33:19 +00:00 incelendi
elegaanz (github.com konumundan göç edildi) bir yorum yaptı

What you did so far looks great! Thank you for helping with that.

What you did so far looks great! Thank you for helping with that.
elegaanz (github.com konumundan göç edildi) 2019-06-02 16:27:10 +00:00 yorum yaptı

thread::sleep(2 * 60 * 60 * 1000)

More seriously, I think you can pass tuples to diesel::insert_into(...).values(), like:

diesel::insert_into(password_reset_requests::table)
    .values((
        password_reset_requests::email.eq("foo@bar.org"),
        password_reset_requests::token.eq("aaaaaaaaa"),
        password_reset_requests::creation_date.eq(now - 3.hours()),
    ))

You can probably use it instead of PasswordResetRequest::insert in this test.

~~`thread::sleep(2 * 60 * 60 * 1000)`~~ More seriously, I think you can pass tuples to `diesel::insert_into(...).values()`, like: ```rust diesel::insert_into(password_reset_requests::table) .values(( password_reset_requests::email.eq("foo@bar.org"), password_reset_requests::token.eq("aaaaaaaaa"), password_reset_requests::creation_date.eq(now - 3.hours()), )) ``` 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()
elegaanz (github.com konumundan göç edildi) 2019-06-02 16:32:01 +00:00 yorum yaptı

Maybe, instead of mapping the error to to_validation, you could have a closure that returns the specific error that was previously returned?

Maybe, instead of mapping the error to `to_validation`, you could have a closure that returns the specific error that was previously returned?
codecov[bot] 2019-06-04 07:59:46 +00:00 yorum yaptı (github.com konumundan göç edildi)

Codecov Report

No coverage uploaded for pull request base (master@b2312d7). Click here to learn what that means.
The diff coverage is 66.94%.

@@            Coverage Diff            @@
##             master     #610   +/-   ##
=========================================
  Coverage          ?   35.31%           
=========================================
  Files             ?       68           
  Lines             ?     7907           
  Branches          ?     1893           
=========================================
  Hits              ?     2792           
  Misses            ?     4345           
  Partials          ?      770
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/610?src=pr&el=h1) Report > :exclamation: No coverage uploaded for pull request base (`master@b2312d7`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit). > The diff coverage is `66.94%`. ```diff @@ Coverage Diff @@ ## master #610 +/- ## ========================================= Coverage ? 35.31% ========================================= Files ? 68 Lines ? 7907 Branches ? 1893 ========================================= Hits ? 2792 Misses ? 4345 Partials ? 770 ```
rfwatson (github.com konumundan göç edildi) 2019-06-04 17:55:40 +00:00 incelendi
@ -243,4 +223,4 @@
form: Form<NewPasswordForm>,
rockets: PlumeRocket,
) -> Result<Flash<Redirect>, Ructe> {
form.validate()
rfwatson (github.com konumundan göç edildi) 2019-06-04 17:55:40 +00:00 yorum yaptı

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.

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.
rfwatson 2019-06-04 18:06:09 +00:00 yorum yaptı (github.com konumundan göç edildi)

Pretty happy with this now. Still a couple of CI failures but they look random to me

Pretty happy with this now. Still a couple of CI failures but they look random to me
elegaanz 2019-06-04 18:13:11 +00:00 yorum yaptı (github.com konumundan göç edildi)

Yes the CI fails sometimes because it doesn't have enough memory to build…

Yes the CI fails sometimes because it doesn't have enough memory to build…
elegaanz (github.com konumundan göç edildi) 2019-06-04 18:55:05 +00:00 bu değişiklikleri onayladı
elegaanz (github.com konumundan göç edildi) bir yorum yaptı

Everything seems to work fine. Thank you! 😊

Everything seems to work fine. Thank you! :blush:
Bu konuşmaya katılmak için oturum aç.
Değerlendirici yok
Kilometre Taşı Yok
Proje yok
Atanan Kişi Yok
1 participant
Bildirimler
Bitiş Tarihi
Bitiş tarihi geçersiz veya aralık dışında. Lütfen 'yyyy-aa-gg' biçimini kullanın.

Bitiş tarihi atanmadı.

Bağımlılıklar

Bağımlılık yok.

Referans: Plume/Plume#610
Herhangi bir açıklama sağlanmadı.