Merge pull request #23 from lbryio/user-me

fix: prevent multiple user/me calls for new users
This commit is contained in:
Sean Yesmunt 2019-02-03 23:24:22 -05:00 committed by GitHub
commit 2515fcf15d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 13 deletions

19
dist/bundle.js vendored
View file

@ -798,18 +798,18 @@ Lbryio.authenticate = function () {
Lbryio.authenticationPromise = new Promise(function (resolve, reject) {
Lbryio.getAuthToken().then(function (token) {
if (!token || token.length > 60) {
return false;
return [false];
}
// 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

@ -110,17 +110,17 @@ Lbryio.authenticate = () => {
Lbryio.getAuthToken()
.then(token => {
if (!token || token.length > 60) {
return false;
return [false];
}
// 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);
});
}