Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Account: a local-only phone says why it has no code for your computer (#551)
Duarte Santosbf71b05f5748
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c3f4f40b8..850f759da 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -155,6 +155,9 @@ per muscle. Settings → Workout → Fine-tuning turns it off.- **Arabic exercise names wrap the right way round** (#780, thanks @kurktchiev). When a longname breaks onto a second line, the English part in brackets keeps its brackets the right wayround.+- **"Where's my code?"** (#551, thanks @Maximrabd). Signing a computer in with a code from your+ phone only works while the phone is connected to your server. A phone app that keeps everything+ to itself now says so under Settings → Account, and so does the sign-in screen's code sheet.- **The Android update actually installs.** Switch to another app while the new APK comes downand Android quietly refused to open the installer, so the download finished and nothinghappened. Now the installer waits until you're back in openGym. Tap the update again after adiff --git a/docs/FAQ.md b/docs/FAQ.mdindex 5247118c9..fb3941723 100644--- a/docs/FAQ.md+++ b/docs/FAQ.md@@ -113,8 +113,9 @@ Two separate things, both fixable:(the browser shows a QR code, scan it, confirm on the phone), a password manager such asBitwarden, 1Password or Proton Pass, a security key, or Windows Hello with a PIN. If the browseronly ever asks for a fingerprint, look for "use another device" or "use a phone" in that dialog.- Already signed in on your phone? **Settings → Account → Add another device** gives the laptop- a passkey of its own. More in+ Phone connected to this server? **Settings → Account → Add another device** gives the laptop+ a passkey of its own. (A phone app that keeps its data to itself has no code to give until you+ connect it to the server.) More in[which passkey providers work](SELF_HOSTING.md#which-passkey-providers-work).Rather skip passkeys on that device? Put `PASSWORD_LOGIN=1` in `.env`, then `docker compose up -d`diff --git a/docs/SELF_HOSTING.md b/docs/SELF_HOSTING.mdindex 1f1b84ae2..029f946a7 100644--- a/docs/SELF_HOSTING.md+++ b/docs/SELF_HOSTING.md@@ -948,6 +948,10 @@ then creates a passkey of its own and is signed in by it. So a Windows Hello pasthe phone's own passkey can sign in to the same profile, instead of the phone ending up with asecond, empty one. (#95)+The device that makes the code has to be signed in to this server. A phone app that keeps+everything on the phone has no account here and so no such row: connect it first under+**Settings → Account → Connect to my server**, and the row shows up in its Server & sync block. (#551)+Both ways ask you to confirm first — with a passkey the profile already has, or its passwordwhile `PASSWORD_LOGIN=1` — because each adds a lasting way in: a session on its own may be acopied cookie. Removing a passkey asks for the same, since a copied cookie could otherwise pickdiff --git a/frontend/src/components/Passkeys.jsx b/frontend/src/components/Passkeys.jsxindex a1dc5dcd8..104a122e3 100644--- a/frontend/src/components/Passkeys.jsx+++ b/frontend/src/components/Passkeys.jsx@@ -373,6 +373,8 @@ export function DeviceLinkRedeemSheet({ close }) {<div className="muted small" style={{ marginBottom: 14 }}>{joining? t('Create a passkey on this device for the profile “{0}”. It signs you in here from now on.', joining.name): t('Enter the code your other device shows under Settings → Account → Add another device. This device then gets a passkey of its own.')}+ {/* #551: an app that keeps its data on the phone has no account here, so no such row. */}+ {!joining && <div style={{ marginTop: 6 }}>{t('No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.')}</div>}{!joining && <div style={{ marginTop: 6 }}>{t('A recovery code from your admin goes here too.')}</div>}</div>{elsewhere && <div className="card small" style={{ textAlign: 'start', marginBottom: 14 }}>{user && <div style={{ marginBottom: 8 }}>{user.name === joining.namediff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex bcee60028..e8121d0ce 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -2598,4 +2598,6 @@ export default {'How many': 'كم عددها','Fill in': 'املأ','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'هذه المجموعة كلها: {0} {1} هو الأثقل، لذا يبقى الوزن كما هو.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'لا يوجد رمز على هاتفك؟ لا يظهر إلا وهو متصل بهذا الخادم: الإعدادات ← الحساب ← الاتصال بخادمي.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'لتسجيل الدخول على حاسوبك أيضًا تحتاج إلى خادمك الخاص. اربط هذا الهاتف به، وعندها يعطي «إضافة جهاز آخر» الحاسوب رمزًا.',}diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.jsindex 0fa9f03fe..d7da3e243 100644--- a/frontend/src/locales/bn.js+++ b/frontend/src/locales/bn.js@@ -2622,4 +2622,6 @@ export default {'How many': 'কতগুলো','Fill in': 'পূরণ করুন','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'এটাই পুরো স্ট্যাক: {0} {1} সবচেয়ে ভারী, তাই ওজন একই থাকে।',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'ফোনে কোনো কোড নেই? এই সার্ভারে সংযুক্ত থাকলেই কেবল কোড থাকে: সেটিংস → অ্যাকাউন্ট → আমার সার্ভারে সংযোগ করুন।',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'কম্পিউটারেও সাইন ইন করতে আপনার নিজের সার্ভার লাগবে। এই ফোনটি সেখানে সংযোগ করুন, তারপর আরেকটি ডিভাইস যোগ করুন কম্পিউটারকে একটি কোড দেবে।',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 6c12cb731..a3993669d 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -2563,4 +2563,6 @@ export default {'How many': 'Wie viele','Fill in': 'Ausfüllen','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'Das ist der ganze Block: {0} {1} ist das Schwerste, also bleibt das Gewicht.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'Kein Code auf deinem Handy? Den gibt es nur, solange es mit diesem Server verbunden ist: Einstellungen → Konto → Mit meinem Server verbinden.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Um dich auch am Computer anzumelden, brauchst du deinen eigenen Server. Verbinde dieses Handy damit, dann gibt Weiteres Gerät hinzufügen dem Computer einen Code.',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex b5b014279..9326bdf8e 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -2543,4 +2543,6 @@ export default {'How many': 'Cuántos','Fill in': 'Rellenar','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'Es toda la columna: {0} {1} es lo máximo que da, así que el peso se queda.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': '¿No hay código en tu móvil? Solo tiene uno mientras está conectado a este servidor: Ajustes → Cuenta → Conectar a mi servidor.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Para iniciar sesión también en tu ordenador hace falta tu propio servidor. Conecta este móvil a él y Añadir otro dispositivo le dará un código al ordenador.',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 89dd1f419..274ddab33 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -2543,4 +2543,6 @@ export default {'How many': 'Combien','Fill in': 'Remplir','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'C’est toute la pile : {0} {1} est le maximum, donc le poids reste.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'Pas de code sur ton téléphone ? Il n’en a un que s’il est connecté à ce serveur : Réglages → Compte → Se connecter à mon serveur.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Pour te connecter aussi sur ton ordinateur, il te faut ton propre serveur. Connecte ce téléphone à celui-ci, puis Ajouter un autre appareil donne un code à l’ordinateur.',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 74d8f4bff..e0a0e7780 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -2543,4 +2543,6 @@ export default {'How many': 'कितने','Fill in': 'भरें','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'यही पूरा स्टैक है: {0} {1} सबसे भारी है, इसलिए वज़न वही रहता है।',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'फ़ोन पर कोई कोड नहीं? कोड तभी होता है जब वह इस सर्वर से कनेक्ट हो: सेटिंग्स → खाता → मेरे सर्वर से कनेक्ट करें।',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'कंप्यूटर पर भी साइन इन करने के लिए आपका अपना सर्वर चाहिए। इस फ़ोन को उससे कनेक्ट करें, फिर दूसरा डिवाइस जोड़ें कंप्यूटर को एक कोड देगा।',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 482c07806..2b15041f0 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -2546,4 +2546,6 @@ export default {'How many': 'Hány darab','Fill in': 'Kitöltés','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'Ez az egész oszlop: {0} {1} a legtöbb, így a súly marad.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'Nincs kód a telefonodon? Csak akkor van, ha ehhez a szerverhez csatlakozik: Beállítások → Fiók → Csatlakozás a szerveremhez.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Ahhoz, hogy a gépeden is bejelentkezz, saját szerver kell. Csatlakoztasd hozzá ezt a telefont, és a Másik eszköz hozzáadása ad egy kódot a gépnek.',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex d5e82c343..3bb0e0d69 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -2543,4 +2543,6 @@ export default {'How many': 'Quanti','Fill in': 'Compila','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'È tutto il pacco: {0} {1} è il massimo, quindi il peso resta.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'Nessun codice sul telefono? Ne ha uno solo mentre è connesso a questo server: Impostazioni → Account → Connettiti al mio server.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Per accedere anche dal computer serve il tuo server. Collega questo telefono al server e Aggiungi un altro dispositivo darà un codice al computer.',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 0075b4e83..ff3d1eedc 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -2543,4 +2543,6 @@ export default {'How many': '개수','Fill in': '채우기','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': '스택 끝이에요: {0} {1}이(가) 가장 무거우니 무게를 유지해요.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': '휴대폰에 코드가 없나요? 이 서버에 연결되어 있을 때만 코드가 있어요: 설정 → 계정 → 내 서버에 연결.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': '컴퓨터에서도 로그인하려면 내 서버가 필요해요. 이 휴대폰을 서버에 연결하면 다른 기기 추가가 컴퓨터에 쓸 코드를 줘요.',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex ebd5ce17d..21b2e7f38 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -2543,4 +2543,6 @@ export default {'How many': 'Ile','Fill in': 'Wypełnij','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'To cały stos: {0} {1} to najwięcej, więc ciężar zostaje.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'Nie ma kodu na telefonie? Pojawia się tylko, gdy telefon jest połączony z tym serwerem: Ustawienia → Konto → Połącz z moim serwerem.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Żeby logować się też na komputerze, potrzebujesz własnego serwera. Połącz z nim ten telefon, a Dodaj kolejne urządzenie da komputerowi kod.',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 4d43c5c73..95e26f808 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1636,6 +1636,8 @@ export const PT_BR_OVERRIDES = {"Remove range": "Remover faixa",'No list yet, so this exercise steps by its increment as usual.': 'Ainda sem lista, então este exercício sobe pelo seu incremento, como sempre.','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'É o bloco todo: {0} {1} é o máximo que dá, então o peso fica.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'Não tem código no celular? Ele só aparece enquanto o celular está conectado a este servidor: Configurações → Conta → Conectar ao meu servidor.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Para entrar também no computador, você precisa do seu próprio servidor. Conecte este celular a ele, e Adicionar outro dispositivo dá um código para o computador.',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 7b7722291..4ea756306 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -2543,4 +2543,6 @@ export default {'How many': 'Quantos','Fill in': 'Preencher','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'É o bloco todo: {0} {1} é o máximo que dá, por isso o peso fica.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'Não há código no telemóvel? Só tem um enquanto está ligado a este servidor: Definições → Conta → Ligar ao meu servidor.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Para iniciar sessão também no computador precisas do teu próprio servidor. Liga este telemóvel a ele e Adicionar outro dispositivo dá um código ao computador.',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 6e0e4f818..d06353a17 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -2547,4 +2547,6 @@ export default {'How many': 'Сколько','Fill in': 'Заполнить','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'Это весь стек: {0} {1} и есть максимум, так что вес остаётся.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'На телефоне нет кода? Он появляется, только пока телефон подключён к этому серверу: Настройки → Аккаунт → Подключиться к моему серверу.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Чтобы входить и с компьютера, нужен ваш собственный сервер. Подключите к нему этот телефон, и «Добавить другое устройство» выдаст компьютеру код.',}diff --git a/frontend/src/locales/sv.js b/frontend/src/locales/sv.jsindex ede066bea..d76a352da 100644--- a/frontend/src/locales/sv.js+++ b/frontend/src/locales/sv.js@@ -2590,4 +2590,6 @@ export default {'How many': 'Hur många','Fill in': 'Fyll i','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'Det är hela stacken: {0} {1} är det tyngsta, så vikten står kvar.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'Ingen kod på telefonen? Den finns bara medan telefonen är ansluten till den här servern: Inställningar → Konto → Anslut till min server.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'För att logga in på datorn också behöver du en egen server. Anslut telefonen till den, så ger Lägg till en annan enhet datorn en kod.',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex f952d78f8..297e9ecf5 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -2554,4 +2554,6 @@ export default {'How many': 'กี่ค่า','Fill in': 'เติม','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'สุดสแต็กแล้ว: {0} {1} หนักที่สุด น้ำหนักจึงคงเดิม',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'ไม่มีรหัสในโทรศัพท์? จะมีรหัสก็ต่อเมื่อเชื่อมต่อกับเซิร์ฟเวอร์นี้อยู่: ตั้งค่า → บัญชี → เชื่อมต่อกับเซิร์ฟเวอร์ของฉัน',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'หากจะเข้าสู่ระบบบนคอมพิวเตอร์ด้วย ต้องมีเซิร์ฟเวอร์ของคุณเอง เชื่อมต่อโทรศัพท์นี้กับเซิร์ฟเวอร์ แล้วเพิ่มอุปกรณ์อื่นจะให้รหัสกับคอมพิวเตอร์',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 9e1afaf4a..920b8b981 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -2543,4 +2543,6 @@ export default {'How many': 'Kaç tane','Fill in': 'Doldur','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'Bloğun tamamı bu: {0} {1} en ağırı, o yüzden ağırlık sabit kalır.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'Telefonunda kod yok mu? Kod yalnızca bu sunucuya bağlıyken olur: Ayarlar → Hesap → Sunucuma bağlan.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Bilgisayarda da giriş yapmak için kendi sunucun gerekir. Bu telefonu ona bağla, ardından Başka bir cihaz ekle bilgisayara bir kod verir.',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 17727da7e..3a9193bbe 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -2540,4 +2540,6 @@ export default {'How many': 'Скільки','Fill in': 'Заповнити','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': 'Це весь стек: {0} {1} і є максимум, тож вага лишається.',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': 'На телефоні немає коду? Він є, лише поки телефон підключений до цього сервера: Налаштування → Акаунт → Підключитися до мого сервера.',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': 'Щоб входити й на комп’ютері, потрібен твій власний сервер. Підключи до нього цей телефон, і «Додати інший пристрій» дасть комп’ютеру код.',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex bfbbeb2cc..8672b92e9 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -2536,4 +2536,6 @@ export default {'How many': '數量','Fill in': '填入','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': '已經到底了:{0} {1} 是最重的一檔,所以重量不變。',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': '手機上沒有代碼?只有連線至這個伺服器時才會有:設定 → 帳號 → 連線至我的伺服器。',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': '想在電腦上也登入,需要你自己的伺服器。把這支手機連線上去,然後「新增其他裝置」就會給電腦一組代碼。',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex bea05f86f..f4f7aaa97 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -2543,4 +2543,6 @@ export default {'How many': '数量','Fill in': '填入','That’s the whole stack: {0} {1} is the heaviest it goes, so the weight stays.': '已经到底了:{0} {1} 是最重的一档,所以重量不变。',+ 'No code on your phone? It only has one while it’s connected to this server: Settings → Account → Connect to my server.': '手机上没有代码?只有连接到这个服务器时才会有:设置 → 账号 → 连接到我的服务器。',+ 'Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.': '想在电脑上也登录,需要你自己的服务器。把这部手机连接上去,然后“添加其他设备”就会给电脑一个代码。',}diff --git a/frontend/src/views/Login.device-link.test.jsx b/frontend/src/views/Login.device-link.test.jsxindex e9b26fd3f..5aefcbf17 100644--- a/frontend/src/views/Login.device-link.test.jsx+++ b/frontend/src/views/Login.device-link.test.jsx@@ -62,6 +62,8 @@ describe('Login: a code from another device', () => {const sheet = mount(mocks.sheets[0](() => {}))expect(sheet.querySelector('h3').textContent).toBe('Add this device')expect(sheet.querySelector('input[placeholder="Code from your other device"]')).toBeTruthy()+ // #551: a phone that keeps everything to itself has no code to give, and the sheet says so.+ expect(sheet.textContent).toContain('It only has one while it’s connected to this server')})it('is not offered in a browser that cannot make a passkey, with or without passwords', () => {diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsxindex ef3d70457..ae2449e91 100644--- a/frontend/src/views/Settings.jsx+++ b/frontend/src/views/Settings.jsx@@ -971,7 +971,9 @@ export default function Settings({ page = null, find = null, via = null, entryKe</ServerSyncSection>}{/* account (demo and mobile builds have nothing to sign in to) */}- {!(MOBILE && user) && <Section title={MOBILE ? t('Your data') : DEMO ? t('Demo') : t('Account')}>+ {/* A local-only phone has no account to hand another device a code for (#551). */}+ {!(MOBILE && user) && <Section title={MOBILE ? t('Your data') : DEMO ? t('Demo') : t('Account')}+ footer={MOBILE ? t('Signing in on your computer too needs your own server. Connect this phone to it, and Add another device then gives the computer a code.') : null}>{MOBILE ? <><Row icon="lock" iconTint="var(--acc)" title={t('All data stays on this phone')} subtitle={t('No account, no cloud. Back it up anytime in Data & backup.')} /><Row icon="cloud" iconTint="var(--indigo)" title={t('Connect to my server')} subtitle={t('Sync this device to your own self-hosted openGym instead.')} accessory="chevron"diff --git a/frontend/src/views/Settings.passkeys.test.jsx b/frontend/src/views/Settings.passkeys.test.jsxindex 082f25e66..7922d43f5 100644--- a/frontend/src/views/Settings.passkeys.test.jsx+++ b/frontend/src/views/Settings.passkeys.test.jsx@@ -13,7 +13,7 @@ globalThis.IS_REACT_ACT_ENVIRONMENT = trueconst mocks = vi.hoisted(() => {// `kept` is one array for good: KeptChangesRows re-asks whenever the function changes, and a// fresh [] per answer would re-render it forever.- const state = { S: null, user: null, sync: null, config: null, webauthn: true, sheets: [], kept: [] }+ const state = { S: null, user: null, sync: null, config: null, webauthn: true, sheets: [], kept: [], MOBILE: false }state.passkeyLogin = vi.fn(async () => ({ id: 'u1', name: 'andi' }))state.list = { passkeys: [{ id: 'k1', name: 'Laptop', created: null, lastUsed: null, transports: [] }, { id: 'k2', name: null, created: null, lastUsed: null, transports: [] }], password: true, lastWayIn: false }state.api = vi.fn(async path => path === '/api/account/password' ? { set: true, setAt: null, passkeys: 2, name: 'andi', nameTaken: false }@@ -44,7 +44,7 @@ vi.mock('../lib/api.js', () => ({}))vi.mock('../lib/push.js', () => ({ pushSupported: () => false, enablePush: vi.fn(), disablePush: vi.fn(), sendTestPush: vi.fn() }))vi.mock('../lib/wakelock.js', () => ({ wakeLockSupported: () => false }))-vi.mock('../lib/mobile.js', () => ({ MOBILE: false, isAndroid: () => Promise.resolve(false), shareExport: vi.fn(), syncReminder: vi.fn() }))+vi.mock('../lib/mobile.js', () => ({ get MOBILE() { return mocks.MOBILE }, isAndroid: () => Promise.resolve(false), shareExport: vi.fn(), syncReminder: vi.fn() }))vi.mock('./MobileOnboarding.jsx', () => ({ ConnectSheet: () => null }))vi.mock('../sheets.jsx', () => ({starterPlanSheet: vi.fn(), confirmSheet: vi.fn(), importFromApp: vi.fn(),@@ -73,6 +73,7 @@ beforeEach(() => {mocks.sync = { status: 'ok', offline: false, pending: false, auth: false, lastError: null, lastSynced: Date.now(), server: null }mocks.config = { password_login: true }mocks.webauthn = true+ mocks.MOBILE = falsemocks.sheets.length = 0mocks.passkeyLogin.mockClear()mocks.api.mockClear()@@ -94,6 +95,28 @@ describe('Settings: passkeys and another device', () => {expect(order.indexOf('Add another device')).toBeLessThan(order.indexOf('Password'))})+ // #551: the code for a computer comes from a phone connected to the server, and a phone that+ // keeps everything on itself says why it has none instead of leaving you to search for it.+ it('a paired phone offers a code for another device in its Server & sync block', async () => {+ mocks.MOBILE = true+ mocks.sync.server = 'https://gym.example.com'+ const page = mount(<Settings page="account" />)+ await settle()+ expect(titles(section(page, 'Server & sync'))).toContain('Add another device')+ expect(section(page, 'Your data')).toBeUndefined()+ })++ it('a local-only phone has no code to give, and says what it takes', async () => {+ mocks.MOBILE = true+ mocks.user = null+ const page = mount(<Settings page="account" />)+ await settle()+ const data = section(page, 'Your data')+ expect(titles(data)).toContain('Connect to my server')+ expect(titles(page)).not.toContain('Add another device')+ expect(data.querySelector('.sect-f').textContent).toContain('needs your own server')+ })+it('a guest gets neither, and nothing is asked', async () => {mocks.user = nullconst page = mount(<Settings page="account" />)