(
State(ctx): State<AppContext>,
Json(params): Json<ForgotParams>,
)
| 89 | /// list). |
| 90 | #[debug_handler] |
| 91 | async fn forgot( |
| 92 | State(ctx): State<AppContext>, |
| 93 | Json(params): Json<ForgotParams>, |
| 94 | ) -> Result<Response> { |
| 95 | let Ok(user) = users::Model::find_by_email(&ctx.db, ¶ms.email).await else { |
| 96 | // we don't want to expose our users email. if the email is invalid we still |
| 97 | // returning success to the caller |
| 98 | return format::json(()); |
| 99 | }; |
| 100 | |
| 101 | let user = user |
| 102 | .into_active_model() |
| 103 | .set_forgot_password_sent(&ctx.db) |
| 104 | .await?; |
| 105 | |
| 106 | AuthMailer::forgot_password(&ctx, &user).await?; |
| 107 | |
| 108 | format::json(()) |
| 109 | } |
| 110 | |
| 111 | /// reset user password by the given parameters |
| 112 | #[debug_handler] |
nothing calls this directly
no test coverage detected