Skip to content

Commit

Permalink
fix a login issue with using 2fa
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Jul 13, 2024
1 parent 532d0e7 commit dc133fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/connection/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`);
Expand Down
7 changes: 6 additions & 1 deletion lib/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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 = {
Expand Down

0 comments on commit dc133fa

Please sign in to comment.