fix(webui): stop inventing a username on password-only app cards

The Login Details card fell back to the literal 'admin' when an app declared no
user or email key, so speedtest — which has a single CFG_SPEEDTEST_PASSWORD_1
and no user concept at all — advertised "User: admin" to anyone reading its
card. There is no such account; the field was fabricated by the fallback.

Show the username row only when a user or email key actually exists, and the
password row only when a password key does. eoCredList already omits any row
whose value is null, so passing undefined for either half renders just the half
that is real.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
librelad 2026-08-18 21:13:30 +01:00
parent 296c6ddff1
commit c9a513abc0

View File

@ -977,14 +977,20 @@ class AppsManager {
const passKeys = Object.keys(cfg).filter(k => loginKey('PASSWORD').test(k));
const emailVal = emailKeys[0] ? cfg[emailKeys[0]] : '';
const userVal = userKeys[0] ? cfg[userKeys[0]] : '';
const identifier = emailVal || userVal || 'admin';
const userLabel = (emailVal || (typeof identifier === 'string' && identifier.includes('@'))) ? 'Email' : 'User';
// Only claim a username when the app actually declares one. This used to
// fall back to the literal 'admin', which invented a login name for
// password-only apps — speedtest has a single CFG_SPEEDTEST_PASSWORD_1 and
// no user concept at all, yet its card advertised "User: admin".
// eoCredList omits any row whose value is null, so passing undefined for
// either half renders just the half that exists.
const identifier = emailVal || userVal;
const userLabel = (emailVal || identifier.includes('@')) ? 'Email' : 'User';
if (userKeys[0] || emailKeys[0] || passKeys[0]) {
creds.push({
title: `${app.name.split(' - ')[0]} Login`,
username: identifier,
username: identifier || undefined,
userLabel,
password: cfg[passKeys[0]] || '(not generated)'
password: passKeys[0] ? (cfg[passKeys[0]] || '(not generated)') : undefined
});
}