From dc133fa658d149bd95182687f1253296b83165ac Mon Sep 17 00:00:00 2001 From: Ben <43026681+bwp91@users.noreply.github.com> Date: Sat, 13 Jul 2024 18:46:04 +0100 Subject: [PATCH] fix a login issue with using 2fa --- CHANGELOG.md | 6 ++++++ lib/connection/http.js | 2 ++ lib/platform.js | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0edc9c3..e08eae9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ This project tries to adhere to [Semantic Versioning](http://semver.org/). In pr - `MINOR` version when a new device type is added, or when a new feature is added that is backwards-compatible - `PATCH` version when backwards-compatible bug fixes are implemented +## 10.5.1 (2024-07-13) + +### Fixed + +- fix a login issue with using 2fa + ## 10.5.0 (2024-07-13) ### Added diff --git a/lib/connection/http.js b/lib/connection/http.js index baa995ef..1e33869d 100644 --- a/lib/connection/http.js +++ b/lib/connection/http.js @@ -224,6 +224,8 @@ export default class { await this.login(); return this.getDevices(); } + + await this.storageData.removeItem('Meross_All_Devices_temp'); throw new Error(platformLang.accTokenInvalid); } throw new Error(`${platformLang.invalidDevices} - ${JSON.stringify(res.data)}`); diff --git a/lib/platform.js b/lib/platform.js index ad099d7a..f866282d 100644 --- a/lib/platform.js +++ b/lib/platform.js @@ -365,12 +365,17 @@ export default class { this.log.debug('[HTTP] %s.', platformLang.accTokenFromCache); this.cloudClient = new httpClient(this); + this.accountDetails = await this.cloudClient.login(); } catch (err) { this.log.warn('[HTTP] %s %s.', platformLang.accTokenFail, parseError(err, [ platformLang.accTokenUserChange, platformLang.accTokenNoExist, + platformLang.accTokenInvalid, ])); + // Remove existing cache info if it exists + await this.storageData.removeItem('Meross_All_Devices_temp'); + this.cloudClient = new httpClient(this); this.accountDetails = await this.cloudClient.login(); } @@ -379,7 +384,7 @@ export default class { cloudDevices = await this.cloudClient.getDevices(); cloudDevices.forEach((device) => this.initialiseDevice(device)); } catch (err) { - const eText = parseError(err, [platformLang.mfaFail, platformLang.missingCreds]); + const eText = parseError(err, [platformLang.mfaFail, platformLang.missingCreds, platformLang.accTokenInvalid]); this.log.warn('%s %s.', platformLang.disablingCloud, eText); this.cloudClient = false; this.accountDetails = {