Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

An account with nowhere to send a code is told so, and what to do

Yashwanth Kamireddi048fe195877b
diff --git a/.uiverify/assert.mjs b/.uiverify/assert.mjs
index 7c1847c..36b0f61 100644
--- a/.uiverify/assert.mjs
+++ b/.uiverify/assert.mjs
@@ -369,6 +369,60 @@ let failures = 0;
await page.close();
}
+// ── An account with nowhere to send a code ────────────────────────────────────────────
+// No trusted device and no trusted number. The screen must not offer a code that can never
+// arrive, and must say what would actually help — otherwise it is a dead end with a text box
+// in the middle of it.
+{
+ for (const [label, twoFactor, wants] of [
+ ["nowhere to send", { trustedDeviceCount: 0, phones: [], tooManyCodesSent: false },
+ { resend: false, text: false, says: /account\.apple\.com/ }],
+ ["no device, but a number", { trustedDeviceCount: 0, phones: [{ id: 1, maskedNumber: "+91 •••318" }], tooManyCodesSent: false },
+ { resend: false, text: true, says: /texted/i }],
+ ["devices and a number", { trustedDeviceCount: 2, phones: [{ id: 1, maskedNumber: "+91 •••318" }], tooManyCodesSent: false },
+ { resend: true, text: true, says: /2 of your devices/ }],
+ ]) {
+ const page = await ctx.newPage();
+ await page.addInitScript((tf) => {
+ window.__TAURI_INTERNALS__ = {
+ transformCallback: (cb) => cb,
+ invoke: async (cmd) => {
+ if (cmd === "auth_status") return { hasStoredSession: false, signedIn: false };
+ if (cmd === "auth_sign_in") return "needs_two_factor";
+ if (cmd === "auth_two_factor_options") return tf;
+ if (cmd === "plugin:event|listen") return 0;
+ return null;
+ },
+ };
+ }, twoFactor);
+ await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+ await page.fill('input[aria-label="Apple ID"]', "[email protected]");
+ await page.fill('input[aria-label="Password"]', "hunter2hunter2");
+ await page.click('button[type="submit"]');
+ await page.waitForSelector(".code", { timeout: 5000 });
+ // Where no device is reachable the help opens by itself, so there is nothing to click.
+ const opener = page.locator("button", { hasText: /get a code/ });
+ if (await opener.count()) await opener.click();
+ await page.waitForTimeout(250);
+
+ const body = await page.locator(".sheet").innerText();
+ const resend = await page.locator('button:has-text("Send to my devices again")').count();
+ const text = await page.locator('button:has-text("Text ")').count();
+
+ const right =
+ (resend > 0) === wants.resend &&
+ (text > 0) === wants.text &&
+ wants.says.test(body);
+ console.log(
+ right
+ ? `PASS ${label}: offers only what can work`
+ : `FAIL ${label}: resend=${resend} text=${text}, said ${JSON.stringify(body.slice(0, 90))}`
+ );
+ if (!right) failures++;
+ await page.close();
+ }
+}
+
// ── What somebody is told before they type an Apple ID in ─────────────────────────────
// Required rather than nice to have: this is software a stranger wrote, reaching iCloud
// through interfaces Apple has not published. Shut, it must not shout; open, it must say so.
diff --git a/.uiverify/shots.mjs b/.uiverify/shots.mjs
index b1eefd9..6fcfdfc 100644
--- a/.uiverify/shots.mjs
+++ b/.uiverify/shots.mjs
@@ -192,6 +192,9 @@ function installStub({ screen, services, twoFactor, calendarFixture, notesFixtur
const PUSHED = { trustedDeviceCount: 2, phones: [{ id: 1, maskedNumber: "+91 ••••• ••318" }], tooManyCodesSent: false };
const NOTHING = { trustedDeviceCount: 0, phones: [{ id: 1, maskedNumber: "+91 ••••• ••318" }], tooManyCodesSent: false };
+// No device to prompt and no number to text. Rare, and real — an account whose trusted number
+// was removed. Without a screen of its own it offers a code that can never arrive.
+const NOWHERE = { trustedDeviceCount: 0, phones: [], tooManyCodesSent: false };
const shots = [
{ name: "01-signin", screen: "signin", theme: "light" },
@@ -206,6 +209,13 @@ const shots = [
await p.fill('input[aria-label="Digit 2"]', "8");
await p.fill('input[aria-label="Digit 3"]', "1");
} },
+ { name: "19-code-nowhere", screen: "code", theme: "light", twoFactor: NOWHERE,
+ act: async (p) => {
+ await p.fill('input[aria-label="Apple ID"]', "[email protected]");
+ await p.fill('input[aria-label="Password"]', "••••••••••••");
+ await p.click('button[type="submit"]');
+ await p.waitForSelector(".help", { timeout: 5000 });
+ } },
{ name: "06-code-no-device", screen: "code", theme: "light", twoFactor: NOTHING,
act: async (p) => {
await p.fill('input[aria-label="Apple ID"]', "[email protected]");
diff --git a/src/screens/CodeEntry.tsx b/src/screens/CodeEntry.tsx
index ef94e51..8271d5a 100644
--- a/src/screens/CodeEntry.tsx
+++ b/src/screens/CodeEntry.tsx
@@ -25,6 +25,14 @@ export function CodeEntry({
// If Apple pushed to nothing, say so immediately rather than letting someone wait.
const nothingSent = options?.trustedDeviceCount === 0;
+ /**
+ * No device to prompt and no number to text.
+ *
+ * Rare, and real — an account whose trusted number was removed, or one reached from a place
+ * its devices are not. Without saying so the screen offers a code that can never arrive and
+ * no way out of it, which is a dead end with a text box in the middle.
+ */
+ const nowhereToSend = nothingSent && options.phones.length === 0;
useEffect(() => {
if (nothingSent) setShowHelp(true);
}, [nothingSent]);
@@ -65,9 +73,11 @@ export function CodeEntry({
<p className="lede">
{options === null
? "Apple sent a six-digit code to your trusted devices."
- : nothingSent
- ? "No trusted device is available."
- : `Apple sent a six-digit code to ${options.trustedDeviceCount} of your devices.`}
+ : nowhereToSend
+ ? "Apple has nowhere to send a code for this account."
+ : nothingSent
+ ? "None of your devices are reachable, but a code can still be texted to you."
+ : `Apple sent a six-digit code to ${options.trustedDeviceCount} of your devices.`}
</p>
<CodeInput value={code} onChange={setCode} onComplete={verify} disabled={busy} />
@@ -90,10 +100,18 @@ export function CodeEntry({
</p>
)}
- <p>
- The code is only created once you tap <strong>Allow</strong> on your iPhone. If no
- prompt appeared, no code exists yet.
- </p>
+ {nowhereToSend ? (
+ <p>
+ This account has no trusted device and no trusted phone number, so there is
+ nothing here that can produce a code. Sign in on a device you still have, or add
+ a trusted number at <strong>account.apple.com</strong>, and then come back.
+ </p>
+ ) : (
+ <p>
+ The code is only created once you tap <strong>Allow</strong> on your iPhone. If
+ no prompt appeared, no code exists yet.
+ </p>
+ )}
<div className="help-actions">
{!nothingSent && (