mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-25 00:25:03 +08:00
Sentry fix: handle Identity fetch edge cases correctly
This commit is contained in:
parent
6028e8a292
commit
62907af737
1 changed files with 11 additions and 5 deletions
|
@ -76,8 +76,10 @@ class IdentityStore extends MailspringStore {
|
|||
|
||||
// allow someone to call saveIdentity without the token,
|
||||
// and only save it if it's been changed (expensive call.)
|
||||
const nextToken = token || this._identity.token;
|
||||
if (nextToken && nextToken !== this._identity.token) {
|
||||
const oldToken = this._identity ? this._identity.token : null;
|
||||
const nextToken = token || oldToken;
|
||||
|
||||
if (nextToken && nextToken !== oldToken) {
|
||||
// Note: We /must/ await this because calling config.set below
|
||||
// will try to retrieve the password via getPassword.
|
||||
// If this fails, the app may quit here.
|
||||
|
@ -176,11 +178,15 @@ class IdentityStore extends MailspringStore {
|
|||
method: 'GET',
|
||||
});
|
||||
|
||||
if (!json || !json.id || json.id !== this._identity.id) {
|
||||
console.error(json);
|
||||
AppEnv.reportError(new Error('Remote Identity returned invalid json'), json || {});
|
||||
if (!json || !json.id) {
|
||||
AppEnv.reportError(new Error('/api/me returned invalid json'), json || {});
|
||||
return this._identity;
|
||||
}
|
||||
|
||||
if (json.id !== this._identity.id) {
|
||||
console.log('Note: server returned a different identity object.');
|
||||
}
|
||||
|
||||
const nextIdentity = Object.assign({}, this._identity, json);
|
||||
await this.saveIdentity(nextIdentity);
|
||||
return this._identity;
|
||||
|
|
Loading…
Reference in a new issue