web: force update token if email is already confirmed (#2879)

This commit is contained in:
Abdullah Atta
2023-07-04 16:50:52 +05:00
committed by GitHub
parent 60667149d4
commit 3f0a656a36

View File

@@ -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;