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
Sign-in: a reset code asks for the new password twice, like creating a profile and changing a password do (#118)
Duarte Santosaaa36b7a1f77
diff --git a/frontend/src/components/PasswordAuth.jsx b/frontend/src/components/PasswordAuth.jsxindex 3d27d301f..3ecc1a903 100644--- a/frontend/src/components/PasswordAuth.jsx+++ b/frontend/src/components/PasswordAuth.jsx@@ -76,6 +76,7 @@ export function PasswordSignInSheet({ close, onPasskey }) {const [pw, setPw] = useState('')const [code, setCode] = useState('')const [next, setNext] = useState('')+ const [again, setAgain] = useState('')const [busy, setBusy] = useState(false)const [err, setErr] = useState(null)const nameRef = useRef(null)@@ -89,6 +90,8 @@ export function PasswordSignInSheet({ close, onPasskey }) {: !reset && !pw ? t('Enter your password.'): reset && !code.trim() ? t('Enter the reset code.'): reset && length(next) < MIN_PASSWORD ? t('Use at least {0} characters.', MIN_PASSWORD)+ // A typo here is only found at the next sign-in, and fixing it takes another code.+ : reset && next !== again ? t('The two passwords are not the same.'): nullif (bad) { setErr(bad); return }setBusy(true); setErr(null)@@ -111,6 +114,9 @@ export function PasswordSignInSheet({ close, onPasskey }) {<div style={{ height: 10 }} /><input className="input" type="password" name="new-password" autoComplete="new-password" placeholder={t('New password')}value={next} onChange={e => setNext(e.target.value)} />+ <div style={{ height: 10 }} />+ <input className="input" type="password" name="new-password-again" autoComplete="new-password" placeholder={t('Repeat the password')}+ value={again} onChange={e => setAgain(e.target.value)} /><div className="dim small" style={{ marginTop: 6 }}>{t('At least {0} characters. A few unrelated words make a good one.', MIN_PASSWORD)}</div></> : <input className="input" type="password" name="password" autoComplete="current-password" placeholder={t('Password')}value={pw} onChange={e => setPw(e.target.value)} />}diff --git a/frontend/src/components/PasswordAuth.test.jsx b/frontend/src/components/PasswordAuth.test.jsxindex 642963998..4f6b27c54 100644--- a/frontend/src/components/PasswordAuth.test.jsx+++ b/frontend/src/components/PasswordAuth.test.jsx@@ -132,7 +132,7 @@ describe('PasswordSignInSheet', () => {expect(close).not.toHaveBeenCalled()})- it('redeems a reset code with a new password; a too-short one is caught before any request', async () => {+ it('redeems a reset code with a new password; a too-short or mistyped one is caught before any request', async () => {mocks.passwordResetRedeem.mockResolvedValue({ id: 'u1', name: 'Ana' })const host = mount(<PasswordSignInSheet close={() => {}} />)act(() => button(host, 'Have a reset code from your admin?').click())@@ -143,7 +143,15 @@ describe('PasswordSignInSheet', () => {await submit(host)expect(alertText(host)).toBe('Use at least 10 characters.')expect(mocks.passwordResetRedeem).not.toHaveBeenCalled()+ // A typo would only show at the next sign-in, and cost another code from the admin.+ const again = byPlaceholder(host, 'Repeat the password')+ expect(again.getAttribute('autocomplete')).toBe('new-password')type(byPlaceholder(host, 'New password'), 'a brand new passphrase')+ type(again, 'a brand new passphrse')+ await submit(host)+ expect(alertText(host)).toBe('The two passwords are not the same.')+ expect(mocks.passwordResetRedeem).not.toHaveBeenCalled()+ type(again, 'a brand new passphrase')await submit(host)expect(mocks.passwordResetRedeem).toHaveBeenCalledWith('Ana', 'K7WQ-2MZP-4HXA', 'a brand new passphrase')expect(mocks.setUser).toHaveBeenCalled()