Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: implement OTP verification flow and enhance UI for email login

Tonho85058fe689b5
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index ab6d6a89..be8923ce 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -3501,7 +3501,9 @@ dependencies = [
"url",
"urlencoding",
"uuid",
+ "webview2-com",
"which",
+ "windows",
"xz2",
"zip 2.4.2",
]
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 6511b8c1..de221883 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -58,6 +58,10 @@ libloading = "0.8"
which = "7"
librqbit = "8.1.1"
+[target.'cfg(windows)'.dependencies]
+webview2-com = "0.38"
+windows = { version = "0.61", features = ["Win32_System_Com"] }
+
[target.'cfg(any(target_os = "macos", windows, target_os = "linux"))'.dependencies]
tauri-plugin-process = "2.3.1"
tauri-plugin-updater = "2.10.0"
diff --git a/src/lib/i18n/el.json b/src/lib/i18n/el.json
index a31b0f0a..bf413dbf 100644
--- a/src/lib/i18n/el.json
+++ b/src/lib/i18n/el.json
@@ -508,6 +508,9 @@
"login_with_browser": "Σύνδεση μέσω Browser",
"browser": "Browser",
"browser_hint": "Θα ανοίξει ένα παράθυρο browser για να συνδεθείτε. Μετά τη σύνδεση, η συνεδρία σας θα ανιχνευθεί αυτόματα.",
+ "otp_check_email": "Ελέγξτε το email σας για τον κωδικό επαλήθευσης.",
+ "otp_code_label": "Κωδικός Επαλήθευσης",
+ "verify_code": "Επαλήθευση",
"search_placeholder": "Αναζητηση πλατφορμων...",
"connection_failed": "Αποτυχια συνδεσης"
},
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index f5e20b45..c01b6177 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -551,7 +551,10 @@
"search_btn": "Search",
"login_with_browser": "Login with Browser",
"browser": "Browser",
- "browser_hint": "A browser window will open for you to log in. After logging in, your session will be detected automatically."
+ "browser_hint": "A browser window will open for you to log in. After logging in, your session will be detected automatically.",
+ "otp_check_email": "Check your email for the verification code.",
+ "otp_code_label": "Verification Code",
+ "verify_code": "Verify Code"
},
"hotmart": {
"title": "Hotmart",
diff --git a/src/lib/i18n/fr.json b/src/lib/i18n/fr.json
index 8364ad93..33d43911 100644
--- a/src/lib/i18n/fr.json
+++ b/src/lib/i18n/fr.json
@@ -508,6 +508,9 @@
"login_with_browser": "Se connecter via le navigateur",
"browser": "Navigateur",
"browser_hint": "Une fenêtre de navigateur s'ouvrira pour vous connecter. Après la connexion, votre session sera détectée automatiquement.",
+ "otp_check_email": "Vérifiez votre email pour le code de vérification.",
+ "otp_code_label": "Code de Vérification",
+ "verify_code": "Vérifier le Code",
"search_placeholder": "Rechercher des plateformes...",
"connection_failed": "Echec de connexion"
},
diff --git a/src/lib/i18n/it.json b/src/lib/i18n/it.json
index d19cf450..6b99cb25 100644
--- a/src/lib/i18n/it.json
+++ b/src/lib/i18n/it.json
@@ -508,6 +508,9 @@
"login_with_browser": "Accedi con il Browser",
"browser": "Browser",
"browser_hint": "Si aprirà una finestra del browser per effettuare l'accesso. Dopo il login, la sessione verrà rilevata automaticamente.",
+ "otp_check_email": "Controlla la tua email per il codice di verifica.",
+ "otp_code_label": "Codice di Verifica",
+ "verify_code": "Verifica Codice",
"search_placeholder": "Cerca piattaforme...",
"connection_failed": "Connessione fallita"
},
diff --git a/src/lib/i18n/ja.json b/src/lib/i18n/ja.json
index 1a496786..bc5c7030 100644
--- a/src/lib/i18n/ja.json
+++ b/src/lib/i18n/ja.json
@@ -508,6 +508,9 @@
"login_with_browser": "ブラウザでログイン",
"browser": "ブラウザ",
"browser_hint": "ログイン用のブラウザウィンドウが開きます。ログイン後、セッションは自動的に検出されます。",
+ "otp_check_email": "メールで確認コードを確認してください。",
+ "otp_code_label": "確認コード",
+ "verify_code": "確認する",
"search_placeholder": "プラットフォームを検索...",
"connection_failed": "接続に失敗しました"
},
diff --git a/src/lib/i18n/pt.json b/src/lib/i18n/pt.json
index 602d86c8..d4fec35e 100644
--- a/src/lib/i18n/pt.json
+++ b/src/lib/i18n/pt.json
@@ -551,7 +551,10 @@
"search_btn": "Buscar",
"login_with_browser": "Login pelo Navegador",
"browser": "Navegador",
- "browser_hint": "Uma janela do navegador vai abrir para fazer login. Depois de logar, a sessão será detectada automaticamente."
+ "browser_hint": "Uma janela do navegador vai abrir para fazer login. Depois de logar, a sessão será detectada automaticamente.",
+ "otp_check_email": "Verifique seu email para o código de verificação.",
+ "otp_code_label": "Código de Verificação",
+ "verify_code": "Verificar Código"
},
"hotmart": {
"title": "Hotmart",
diff --git a/src/lib/i18n/zh.json b/src/lib/i18n/zh.json
index 042f9c07..7541762a 100644
--- a/src/lib/i18n/zh.json
+++ b/src/lib/i18n/zh.json
@@ -508,6 +508,9 @@
"login_with_browser": "通过浏览器登录",
"browser": "浏览器",
"browser_hint": "将打开一个浏览器窗口供您登录。登录后,您的会话将被自动检测。",
+ "otp_check_email": "请检查您的邮箱获取验证码。",
+ "otp_code_label": "验证码",
+ "verify_code": "验证",
"search_placeholder": "搜索平台...",
"connection_failed": "连接失败"
},
diff --git a/src/routes/courses/[platform]/+page.svelte b/src/routes/courses/[platform]/+page.svelte
index 78ed0bb1..ef56f0ac 100644
--- a/src/routes/courses/[platform]/+page.svelte
+++ b/src/routes/courses/[platform]/+page.svelte
@@ -41,6 +41,8 @@
let loading = $state(false);
let error = $state("");
let captchaWarning = $state(false);
+ let otpSent = $state(false);
+ let otpCode = $state("");
let checking = $state(true);
let loggedIn = $state(false);
@@ -177,6 +179,16 @@
loading = true;
try {
+ if (currentMethod.method_type === "email_only" && otpSent) {
+ const result = await pluginInvoke<string>("courses", `${platformId}_verify_otp`, { email, otpCode });
+ sessionEmail = result || email;
+ loggedIn = true;
+ otpSent = false;
+ otpCode = "";
+ loadItems();
+ return;
+ }
+
const args: Record<string, any> = {};
if (currentMethod.method_type === "email_password") {
@@ -199,11 +211,24 @@
}
const result = await pluginInvoke<string>("courses", currentMethod.command, args);
+
+ if (typeof result === "string" && result === "otp_sent") {
+ otpSent = true;
+ loading = false;
+ return;
+ }
+
sessionEmail = result || email || "OK";
loggedIn = true;
loadItems();
} catch (e: any) {
- error = typeof e === "string" ? e : e.message ?? $t("common.error");
+ const msg = typeof e === "string" ? e : e.message ?? "";
+ if (msg.includes("otp_sent") || msg.includes("OTP sent") || msg.includes("verification code")) {
+ otpSent = true;
+ error = "";
+ } else {
+ error = msg || $t("common.error");
+ }
} finally {
loading = false;
}
@@ -546,8 +571,15 @@
{:else if currentMethod.method_type === "email_only"}
<label class="field">
<span class="field-label">{$t("hotmart.email_label")}</span>
- <input type="email" placeholder={$t("hotmart.email_placeholder")} bind:value={email} class="input" disabled={loading} required />
+ <input type="email" placeholder={$t("hotmart.email_placeholder")} bind:value={email} class="input" disabled={loading || otpSent} required />
</label>
+ {#if otpSent}
+ <p class="otp-hint">{$t("courses.otp_check_email")}</p>
+ <label class="field">
+ <span class="field-label">{$t("courses.otp_code_label")}</span>
+ <input type="text" inputmode="numeric" maxlength="6" placeholder="000000" bind:value={otpCode} class="input otp-input" disabled={loading} required />
+ </label>
+ {/if}
{:else if currentMethod.method_type === "token"}
<label class="field">
<span class="field-label">Token</span>
@@ -576,9 +608,11 @@
<p class="captcha-warning">{$t("hotmart.captcha_detected")}</p>
{/if}
- <button type="submit" class="button" disabled={loading}>
+ <button type="submit" class="button" disabled={loading || (otpSent && otpCode.length < 4)}>
{#if loading}
{$t("hotmart.authenticating")}
+ {:else if otpSent}
+ {$t("courses.verify_code")}
{:else}
{$t("hotmart.login")}
{/if}
@@ -810,6 +844,20 @@
font-size: 12.5px;
}
+ .otp-hint {
+ font-size: 12.5px;
+ color: var(--green);
+ text-align: center;
+ font-weight: 500;
+ }
+
+ .otp-input {
+ text-align: center;
+ font-size: 20px;
+ letter-spacing: 6px;
+ font-family: var(--font-mono);
+ }
+
.browser-hint {
font-size: 12.5px;
color: var(--gray);