From 9a220790efe72820e53a420b1285041cc4bca782 Mon Sep 17 00:00:00 2001 From: benweet Date: Fri, 17 Nov 2017 21:35:57 +0000 Subject: [PATCH] Fixed account name problem --- src/services/providers/helpers/googleHelper.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/services/providers/helpers/googleHelper.js b/src/services/providers/helpers/googleHelper.js index 670d3512..60e582f1 100644 --- a/src/services/providers/helpers/googleHelper.js +++ b/src/services/providers/helpers/googleHelper.js @@ -168,17 +168,21 @@ export default { })) // Call the user info endpoint .then(token => this.getUser(token.sub) - .catch(() => { - store.dispatch('notification/info', 'Please activate Google Plus to change your account name!'); + .catch((err) => { + if (err.status === 404) { + store.dispatch('notification/info', 'Please activate Google Plus to change your account name!'); + } else { + throw err; + } }) .then((user = {}) => { - // Add name to token - token.name = user.displayName || 'Unknown'; const existingToken = store.getters['data/googleTokens'][token.sub]; + // Add name to token + token.name = user.displayName || (existingToken && existingToken.name) || 'Unknown'; if (existingToken) { // We probably retrieved a new token with restricted scopes. // That's no problem, token will be refreshed later with merged scopes. - // Save flags + // Restore flags token.isLogin = existingToken.isLogin || token.isLogin; token.isSponsor = existingToken.isSponsor; token.isDrive = existingToken.isDrive || token.isDrive;