recycleactor commited on
Commit
77f53b5
·
verified ·
1 Parent(s): 662450a

Upload 2 files

Browse files
Files changed (1) hide show
  1. src/main.rs +10 -7
src/main.rs CHANGED
@@ -2125,7 +2125,7 @@ async fn pair_page(Host(host): Host, headers: HeaderMap, Query(q): Query<PairPag
2125
  html.push_str(r#"<button id="dz-login" type="button">Войти через Deezer</button>"#);
2126
  html.push_str(r#"<div id="msg" class="muted" style="margin:12px 0 0"></div>"#);
2127
  html.push_str(r#"<div class="muted" style="margin:12px 0 8px">Рекомендуется OAuth (кнопка выше). Вход по логину/паролю ниже может блокироваться на некоторых прокси/хостингах (403 Access Denied).</div>"#);
2128
- html.push_str(r#"<form method="POST" action="/pair/complete" autocomplete="on" style="margin:10px 0 0">"#);
2129
  html.push_str(r#"<input type="hidden" name="code" value="" id="pair-code-hidden">"#);
2130
  html.push_str(r#"<div class="row"><input name="email" type="email" placeholder="Email" autocomplete="username" required></div>"#);
2131
  html.push_str(r#"<div class="row"><input name="password" type="password" placeholder="Пароль" autocomplete="current-password" required></div>"#);
@@ -2238,14 +2238,17 @@ async fn pair_complete(State(state): State<AppState>, Form(f): Form<PairComplete
2238
  let email = f.email.trim().to_string();
2239
  let password = f.password;
2240
 
 
 
 
2241
  if code.is_empty() || email.is_empty() || password.is_empty() {
2242
- return Html("<h3>Нужны code/email/password</h3>".to_string()).into_response();
2243
  }
2244
 
2245
  {
2246
  let map = state.pair.read().await;
2247
  if !map.contains_key(&code) {
2248
- return Html("<h3>Код не найден или истёк</h3>".to_string()).into_response();
2249
  }
2250
  }
2251
 
@@ -2261,7 +2264,7 @@ async fn pair_complete(State(state): State<AppState>, Form(f): Form<PairComplete
2261
  }
2262
  drop(map);
2263
  pair_store_save(&state).await;
2264
- Html(format!("<h3>Ошибка входа</h3><pre>{}</pre>", htmlesc(&e))).into_response()
2265
  }
2266
  Ok(login) => {
2267
  let email_from_api = {
@@ -2302,11 +2305,11 @@ async fn pair_complete(State(state): State<AppState>, Form(f): Form<PairComplete
2302
  state.api_by_arl.write().await.remove(arl);
2303
  }
2304
  let msg = if login.arl.is_some() {
2305
- "<h3>Готово</h3><p>Вернись на ТВ — плагин подключится автоматически.</p>"
2306
  } else {
2307
- "<h3>Вход выполнен</h3><p>Библиотека доступна. ARL не получен — полные треки могут не работать, попробуй кнопку «Войти через Deezer».</p>"
2308
  };
2309
- Html(msg.to_string()).into_response()
2310
  }
2311
  }
2312
  }
 
2125
  html.push_str(r#"<button id="dz-login" type="button">Войти через Deezer</button>"#);
2126
  html.push_str(r#"<div id="msg" class="muted" style="margin:12px 0 0"></div>"#);
2127
  html.push_str(r#"<div class="muted" style="margin:12px 0 8px">Рекомендуется OAuth (кнопка выше). Вход по логину/паролю ниже может блокироваться на некоторых прокси/хостингах (403 Access Denied).</div>"#);
2128
+ html.push_str(r#"<form method="POST" action="/pair/complete" autocomplete="on" style="margin:10px 0 0" onsubmit="var b=this.querySelector('button');b.disabled=true;b.textContent='Вход... Пожалуйста, подождите';">"#);
2129
  html.push_str(r#"<input type="hidden" name="code" value="" id="pair-code-hidden">"#);
2130
  html.push_str(r#"<div class="row"><input name="email" type="email" placeholder="Email" autocomplete="username" required></div>"#);
2131
  html.push_str(r#"<div class="row"><input name="password" type="password" placeholder="Пароль" autocomplete="current-password" required></div>"#);
 
2238
  let email = f.email.trim().to_string();
2239
  let password = f.password;
2240
 
2241
+ let html_head = r#"<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Deezer Login</title><style>body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;background:#0b0b0b;color:#fff;margin:0;padding:20px}.box{max-width:420px;margin:0 auto;background:#151515;padding:18px;border-radius:12px}.muted{color:#aaa;font-size:13px;line-height:1.35}</style></head><body><div class="box">"#;
2242
+ let html_tail = r#"</div></body></html>"#;
2243
+
2244
  if code.is_empty() || email.is_empty() || password.is_empty() {
2245
+ return Html(format!("{html_head}<h3>Нужны code/email/password</h3>{html_tail}")).into_response();
2246
  }
2247
 
2248
  {
2249
  let map = state.pair.read().await;
2250
  if !map.contains_key(&code) {
2251
+ return Html(format!("{html_head}<h3>Код не найден или истёк</h3>{html_tail}")).into_response();
2252
  }
2253
  }
2254
 
 
2264
  }
2265
  drop(map);
2266
  pair_store_save(&state).await;
2267
+ Html(format!("{html_head}<h3>Ошибка входа</h3><pre style='white-space:pre-wrap;word-break:break-all;color:#ff5a5a'>{}</pre>{html_tail}", htmlesc(&e))).into_response()
2268
  }
2269
  Ok(login) => {
2270
  let email_from_api = {
 
2305
  state.api_by_arl.write().await.remove(arl);
2306
  }
2307
  let msg = if login.arl.is_some() {
2308
+ "<h3>Готово ✓</h3><p class='muted'>Вернись на ТВ — плагин подключится автоматически.</p>"
2309
  } else {
2310
+ "<h3>Вход выполнен</h3><p class='muted'>Библиотека доступна. ARL не получен — полные треки могут не работать, попробуй кнопку «Войти через Deezer».</p>"
2311
  };
2312
+ Html(format!("{html_head}{msg}{html_tail}")).into_response()
2313
  }
2314
  }
2315
  }