diff --git a/packages/core/api/sync/index.js b/packages/core/api/sync/index.js index a7ddbcdfa..b1cbe4a2a 100644 --- a/packages/core/api/sync/index.js +++ b/packages/core/api/sync/index.js @@ -65,6 +65,7 @@ export default class SyncManager { */ constructor(db) { this.sync = new Sync(db); + this._db = db; } async start(full, force) { @@ -76,6 +77,19 @@ export default class SyncManager { var isHubException = e.message.includes("HubException:"); if (isHubException) { var actualError = /HubException: (.*)/gm.exec(e.message); + + // NOTE: sometimes there's the case where the user has already + // confirmed their email but the server still thinks that it + // isn't confirmed. This check is added to trigger a force + // update of the access token. + if ( + actualError.includes("Please confirm your email ") && + (await this._db.user.getUser()).isEmailConfirmed + ) { + await this._db.user.tokenManager._refreshToken(true); + return false; + } + if (actualError.length > 1) throw new Error(actualError[1]); } throw e;