Harden login, sessions, and media access before the dev deploy.
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Successful in 47s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 15s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 5m43s
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Successful in 47s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 15s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 5m43s
Limit brute-force attempts, require admin TOTP, and keep session tokens out of media URLs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6c7c24e887
commit
32b28a93f3
31 files changed
+1146
-101
No files matched your search
@@ -6,6 +6,7 @@ import {
|
||||
resolvePlanningModuleDisplayMode,
|
||||
} from '../config/planningModuleUx'
|
||||
import api from '../utils/api'
|
||||
import TotpSetupCard from '../components/TotpSetupCard'
|
||||
|
||||
/**
|
||||
* Persönliche Einstellungen (Anzeige/Name, Kontostatus, Passwort).
|
||||
@@ -27,6 +28,10 @@ function AccountSettingsPage() {
|
||||
PLANNING_MODULE_DISPLAY_MODES.COMPACT_TAG_LEGEND
|
||||
)
|
||||
|
||||
const [currentPw, setCurrentPw] = useState('')
|
||||
const [disablePw, setDisablePw] = useState('')
|
||||
const [disableCode, setDisableCode] = useState('')
|
||||
const [disablingTotp, setDisablingTotp] = useState(false)
|
||||
const [newPw1, setNewPw1] = useState('')
|
||||
const [newPw2, setNewPw2] = useState('')
|
||||
const [savingPw, setSavingPw] = useState(false)
|
||||
@@ -144,8 +149,8 @@ function AccountSettingsPage() {
|
||||
|
||||
const handleChangePassword = async (e) => {
|
||||
e.preventDefault()
|
||||
if (newPw1.length < 4) {
|
||||
showErr('Neues Passwort: mindestens 4 Zeichen.')
|
||||
if (newPw1.length < 8) {
|
||||
showErr('Neues Passwort: mindestens 8 Zeichen.')
|
||||
return
|
||||
}
|
||||
if (newPw1 !== newPw2) {
|
||||
@@ -154,10 +159,12 @@ function AccountSettingsPage() {
|
||||
}
|
||||
setSavingPw(true)
|
||||
try {
|
||||
await api.changePassword(newPw1)
|
||||
const result = await api.changePassword(currentPw, newPw1)
|
||||
if (result?.token) localStorage.setItem('authToken', result.token)
|
||||
setCurrentPw('')
|
||||
setNewPw1('')
|
||||
setNewPw2('')
|
||||
showOk('Passwort aktualisiert.')
|
||||
showOk('Passwort aktualisiert. Andere Geräte sind abgemeldet.')
|
||||
} catch (err) {
|
||||
showErr(err.message || 'Passwort konnte nicht geändert werden.')
|
||||
} finally {
|
||||
@@ -461,12 +468,72 @@ function AccountSettingsPage() {
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{user?.totp_enabled ? (
|
||||
<div className="card" style={{ marginBottom: '1rem' }}>
|
||||
<h2 style={{ margin: '0 0 0.75rem', fontSize: '1.1rem' }}>Zwei-Faktor ist aktiv</h2>
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.875rem' }}>
|
||||
Beim Anmelden wird zusätzlich der Code aus der Authenticator-App verlangt.
|
||||
</p>
|
||||
{user?.role === 'admin' || user?.role === 'superadmin' ? (
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.875rem' }}>
|
||||
Für Plattform-Admins bleibt das so.
|
||||
</p>
|
||||
) : (
|
||||
<form
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault()
|
||||
setDisablingTotp(true)
|
||||
try {
|
||||
await api.disableTotp(disablePw, disableCode.trim())
|
||||
setDisablePw('')
|
||||
setDisableCode('')
|
||||
showOk('Zwei-Faktor ist aus.')
|
||||
await checkAuth()
|
||||
} catch (err) {
|
||||
showErr(err.message || 'Abschalten fehlgeschlagen')
|
||||
} finally {
|
||||
setDisablingTotp(false)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="form-row" style={{ marginBottom: '0.75rem' }}>
|
||||
<label className="form-label" htmlFor="totp-off-pw">Aktuelles Passwort</label>
|
||||
<input id="totp-off-pw" type="password" className="form-input" value={disablePw} onChange={(e) => setDisablePw(e.target.value)} autoComplete="current-password" />
|
||||
</div>
|
||||
<div className="form-row" style={{ marginBottom: '0.75rem' }}>
|
||||
<label className="form-label" htmlFor="totp-off-code">Code oder Wiederherstellungscode</label>
|
||||
<input id="totp-off-code" className="form-input" value={disableCode} onChange={(e) => setDisableCode(e.target.value)} autoComplete="one-time-code" />
|
||||
</div>
|
||||
<button type="submit" className="btn btn-secondary" disabled={disablingTotp}>
|
||||
{disablingTotp ? 'Wird gespeichert…' : 'Zwei-Faktor ausschalten'}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<TotpSetupCard onEnabled={() => checkAuth()} />
|
||||
)}
|
||||
|
||||
<div className="card">
|
||||
<h2 style={{ margin: '0 0 0.75rem', fontSize: '1.1rem' }}>Passwort ändern</h2>
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.875rem', marginBottom: '1rem', lineHeight: 1.5 }}>
|
||||
Wähle ein neues Passwort (mindestens 4 Zeichen, wie beim Login gewohnt empfehlen wir längere Passwörter).
|
||||
Das aktuelle Passwort wird geprüft. Danach sind andere Sitzungen ungültig. Mindestens 8 Zeichen.
|
||||
</p>
|
||||
<form onSubmit={handleChangePassword}>
|
||||
<div className="form-row" style={{ marginBottom: '0.75rem' }}>
|
||||
<label className="form-label" htmlFor="settings-pw-current">
|
||||
Aktuelles Passwort
|
||||
</label>
|
||||
<input
|
||||
id="settings-pw-current"
|
||||
type="password"
|
||||
className="form-input"
|
||||
value={currentPw}
|
||||
onChange={(e) => setCurrentPw(e.target.value)}
|
||||
autoComplete="current-password"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="form-row" style={{ marginBottom: '0.75rem' }}>
|
||||
<label className="form-label" htmlFor="settings-pw1">
|
||||
Neues Passwort
|
||||
|
||||
Reference in new issue
Block a user