fix: HA Passwort-Auth loggt nicht mehr aus, Radio-Layout korrigiert
- Backend gibt 400 statt 401 bei falschen HA-Credentials zurück, damit der globale api.js-Logout-Handler nicht ausgelöst wird - Null-Guard im JS nach api.post verhindert den "calendars of null"-Crash - Radio-Buttons für Anmeldemethode nicht mehr in form-group, damit input[type=radio] kein width:100% bekommt und sauber nebeneinander liegt
This commit is contained in:
@@ -39,7 +39,7 @@ def _ha_login(url: str, username: str, password: str) -> tuple:
|
|||||||
except http_requests.exceptions.Timeout:
|
except http_requests.exceptions.Timeout:
|
||||||
raise HTTPException(503, "Home Assistant antwortet nicht (Timeout)")
|
raise HTTPException(503, "Home Assistant antwortet nicht (Timeout)")
|
||||||
if resp.status_code in (400, 401):
|
if resp.status_code in (400, 401):
|
||||||
raise HTTPException(401, "Ungültige Anmeldedaten")
|
raise HTTPException(400, "Ungültige Anmeldedaten")
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
return data["access_token"], data.get("refresh_token", ""), data.get("expires_in", 1800)
|
return data["access_token"], data.get("refresh_token", ""), data.get("expires_in", 1800)
|
||||||
@@ -99,7 +99,7 @@ def _ha_get_calendars(url: str, token: str) -> list:
|
|||||||
raise HTTPException(503, "Home Assistant antwortet nicht (Timeout)")
|
raise HTTPException(503, "Home Assistant antwortet nicht (Timeout)")
|
||||||
except http_requests.exceptions.HTTPError as e:
|
except http_requests.exceptions.HTTPError as e:
|
||||||
if e.response is not None and e.response.status_code == 401:
|
if e.response is not None and e.response.status_code == 401:
|
||||||
raise HTTPException(401, "Ungültiger Access Token")
|
raise HTTPException(400, "Ungültiger Access Token")
|
||||||
raise HTTPException(502, f"Home Assistant Fehler: {e}")
|
raise HTTPException(502, f"Home Assistant Fehler: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -416,14 +416,14 @@
|
|||||||
<label>Home Assistant URL</label>
|
<label>Home Assistant URL</label>
|
||||||
<input type="url" id="ha-account-url" placeholder="http://homeassistant.local:8123" />
|
<input type="url" id="ha-account-url" placeholder="http://homeassistant.local:8123" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div style="margin-bottom:16px">
|
||||||
<label>Anmeldemethode</label>
|
<div style="font-size:12px;font-weight:500;text-transform:uppercase;letter-spacing:.5px;color:var(--text-2);margin-bottom:8px">Anmeldemethode</div>
|
||||||
<div style="display:flex;gap:16px">
|
<div style="display:flex;gap:20px">
|
||||||
<label class="toggle-label">
|
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;color:var(--text-1);font-size:14px">
|
||||||
<input type="radio" name="ha-auth-method" value="token" id="ha-auth-token" checked /> Long-Lived Token
|
<input type="radio" name="ha-auth-method" value="token" id="ha-auth-token" checked style="width:auto;accent-color:var(--primary)" /> Long-Lived Token
|
||||||
</label>
|
</label>
|
||||||
<label class="toggle-label">
|
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;color:var(--text-1);font-size:14px">
|
||||||
<input type="radio" name="ha-auth-method" value="password" id="ha-auth-password" /> Benutzername/Passwort
|
<input type="radio" name="ha-auth-method" value="password" id="ha-auth-password" style="width:auto;accent-color:var(--primary)" /> Benutzername/Passwort
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1325,6 +1325,7 @@ function bindHAAccountModal() {
|
|||||||
saveBtn.textContent = 'Verbinde…';
|
saveBtn.textContent = 'Verbinde…';
|
||||||
try {
|
try {
|
||||||
const account = await api.post('/homeassistant/accounts', body);
|
const account = await api.post('/homeassistant/accounts', body);
|
||||||
|
if (!account) return;
|
||||||
state.haAccounts.push(account);
|
state.haAccounts.push(account);
|
||||||
renderCalendarList();
|
renderCalendarList();
|
||||||
closeModal('modal-ha-account');
|
closeModal('modal-ha-account');
|
||||||
|
|||||||
Reference in New Issue
Block a user