(State(ctx): State<AppContext>, Json(params): Json<ResetParams>)
| 111 | /// reset user password by the given parameters |
| 112 | #[debug_handler] |
| 113 | async fn reset(State(ctx): State<AppContext>, Json(params): Json<ResetParams>) -> Result<Response> { |
| 114 | let Ok(user) = users::Model::find_by_reset_token(&ctx.db, ¶ms.token).await else { |
| 115 | // we don't want to expose our users email. if the email is invalid we still |
| 116 | // returning success to the caller |
| 117 | tracing::info!("reset token not found"); |
| 118 | |
| 119 | return format::json(()); |
| 120 | }; |
| 121 | user.into_active_model() |
| 122 | .reset_password(&ctx.db, ¶ms.password) |
| 123 | .await?; |
| 124 | |
| 125 | format::json(()) |
| 126 | } |
| 127 | |
| 128 | /// Creates a user login and returns a token |
| 129 | #[debug_handler] |
nothing calls this directly
no test coverage detected