mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
web: force update token if email is already confirmed (#2879)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user