+ let cached_data = {
+ let mut cache = data.cache_query_reset_game_pwd.lock().await;
+ cache.remove(&form.csrf)
+ };
+ if cached_data.is_none() {
+ log::warn!("Unknown data for CSRF: {}", form.csrf);
+ return HttpResponse::BadRequest().body("Incorrect");
+ }
+
+ if form.contact_type != "email" {
+ log::warn!("Unknown data for contact type: {}", form.contact_type);
+ return HttpResponse::BadRequest().body("Incorrect");
+ }
+
+ // check existence of contact
+ let dbclient_ro = match data.pool_ro.get().await {
+ Ok(c) => c,
+ Err(e) => {
+ log::error!("Pool RO error {}", e);
+ return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
+ }
+ };
+ let stmt = match dbclient_ro.prepare("select 1 from auth.users u inner join auth.contacts c on u.player_name = c.player_name and c.is_active = true and c.delete_ts is null where u.player_name = $1 and c.protocol = ($2::text)::auth.contact_protocol and c.address = $3 limit 1").await {
+ Ok(stmt) => stmt,
+ Err(e) => {
+ log::error!("Pool RO statement error {}", e);
+ return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
+ }
+ };
+ let rows = match dbclient_ro
+ .query_opt(&stmt, &[&form.login, &form.contact_type, &form.contact])
+ .await
+ {
+ Ok(rows) => rows,
+ Err(e) => {
+ log::error!("Pool RO query error {}", e);
+ return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
+ }
+ };
+ if rows.is_none() {
+ return HttpResponse::NotFound().body("Not found");
+ }
+