fix: prevent multiple user/me calls for new users

This commit is contained in:
Sean Yesmunt 2019-02-04 11:55:56 -05:00
parent 83c275da7a
commit 28697c9968
2 changed files with 21 additions and 11 deletions

17
dist/bundle.js vendored
View file

@ -802,14 +802,14 @@ Lbryio.authenticate = function () {
}
// check that token works
return Lbryio.getCurrentUser().then(function () {
return true;
return Lbryio.getCurrentUser().then(function (user) {
return user;
}).catch(function () {
return false;
});
}).then(function (isTokenValid) {
if (isTokenValid) {
return reject;
}).then(function (user) {
if (user) {
return user;
}
return _lbryRedux.Lbry.status().then(function (status) {
@ -827,7 +827,12 @@ Lbryio.authenticate = function () {
return reject();
});
}).then(Lbryio.getCurrentUser).then(resolve, reject);
}).then(function (user) {
if (!user) {
return Lbryio.getCurrentUser();
}
return user;
}).then(resolve, reject);
});
}

View file

@ -115,12 +115,12 @@ Lbryio.authenticate = () => {
// check that token works
return Lbryio.getCurrentUser()
.then(() => true)
.then(user => user)
.catch(() => false);
})
.then(isTokenValid => {
if (isTokenValid) {
return reject;
.then(user => {
if (user) {
return user;
}
return Lbry.status().then(status => {
@ -137,7 +137,12 @@ Lbryio.authenticate = () => {
return reject();
});
})
.then(Lbryio.getCurrentUser)
.then(user => {
if (!user) {
return Lbryio.getCurrentUser();
}
return user;
})
.then(resolve, reject);
});
}