Fixed account name problem

This commit is contained in:
benweet 2017-11-17 21:35:57 +00:00
parent dd336fab3f
commit 9a220790ef

View File

@ -168,17 +168,21 @@ export default {
}))
// Call the user info endpoint
.then(token => this.getUser(token.sub)
.catch(() => {
.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;