Просмотр исходного кода

Always save options; only refuse to save password when auth fails

ZiB 4 месяцев назад
Родитель
Сommit
7b3271780e
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      custom_components/room_cal_ha/config_flow.py

+ 5 - 5
custom_components/room_cal_ha/config_flow.py

@@ -113,9 +113,10 @@ class RoomCalOptionsFlow(OptionsFlow):
     errors: dict[str, str] = {}
     errors: dict[str, str] = {}
 
 
     if user_input is not None:
     if user_input is not None:
+      username = user_input.pop(CONF_USERNAME, "") or self.config_entry.data.get(CONF_USERNAME, "")
+      password = user_input.pop(CONF_PASSWORD, "") or self.config_entry.data.get(CONF_PASSWORD, "")
+
       if user_input.get(CONF_CALDAV_ENABLED) and user_input.get(CONF_CALDAV_URL):
       if user_input.get(CONF_CALDAV_ENABLED) and user_input.get(CONF_CALDAV_URL):
-        username = user_input.pop(CONF_USERNAME, "") or self.config_entry.data.get(CONF_USERNAME, "")
-        password = user_input.pop(CONF_PASSWORD, "") or self.config_entry.data.get(CONF_PASSWORD, "")
         try:
         try:
           await self.hass.async_add_executor_job(
           await self.hass.async_add_executor_job(
             _test_caldav_auth,
             _test_caldav_auth,
@@ -133,9 +134,8 @@ class RoomCalOptionsFlow(OptionsFlow):
             data={**self.config_entry.data, CONF_USERNAME: username, CONF_PASSWORD: password},
             data={**self.config_entry.data, CONF_USERNAME: username, CONF_PASSWORD: password},
           )
           )
 
 
-      if not errors:
-        merged = {**self.config_entry.options, **user_input}
-        return self.async_create_entry(data=merged)
+      merged = {**self.config_entry.options, **user_input}
+      return self.async_create_entry(data=merged)
 
 
     opts = self.config_entry.options
     opts = self.config_entry.options
     data = self.config_entry.data
     data = self.config_entry.data