From 47042ac3de6f4edb96616015fdfaf5f21cc17bed Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Mon, 19 Feb 2024 00:24:48 +0100 Subject: [PATCH] Use update, reload and abort helper in reauth documentation (#2083) --- docs/config_entries_config_flow_handler.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/config_entries_config_flow_handler.md b/docs/config_entries_config_flow_handler.md index 796c2aa1..4e2b2037 100644 --- a/docs/config_entries_config_flow_handler.md +++ b/docs/config_entries_config_flow_handler.md @@ -303,12 +303,14 @@ class OAuth2FlowHandler( async def async_oauth_create_entry(self, data: dict) -> dict: """Create an oauth config entry or update existing entry for reauth.""" - if self._reauth_entry: - self.hass.config_entries.async_update_entry(self.reauth_entry, data=data) - await self.hass.config_entries.async_reload(self.reauth_entry.entry_id) - return self.async_abort(reason="reauth_successful") + if self.reauth_entry: + return self.async_update_reload_and_abort( + self.reauth_entry, + data=data, + ) return await super().async_oauth_create_entry(data) ``` +By default, the `async_update_reload_and_abort` helper method aborts the flow with `reauth_successful` after update and reload. Depending on the details of the integration, there may be additional considerations such as ensuring the same account is used across reauth, or handling multiple config entries.