Merge pull request #23 from lbryio/user-me
fix: prevent multiple user/me calls for new users
This commit is contained in:
commit
2515fcf15d
2 changed files with 23 additions and 13 deletions
19
dist/bundle.js
vendored
19
dist/bundle.js
vendored
|
@ -798,18 +798,18 @@ Lbryio.authenticate = function () {
|
||||||
Lbryio.authenticationPromise = new Promise(function (resolve, reject) {
|
Lbryio.authenticationPromise = new Promise(function (resolve, reject) {
|
||||||
Lbryio.getAuthToken().then(function (token) {
|
Lbryio.getAuthToken().then(function (token) {
|
||||||
if (!token || token.length > 60) {
|
if (!token || token.length > 60) {
|
||||||
return false;
|
return [false];
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that token works
|
// check that token works
|
||||||
return Lbryio.getCurrentUser().then(function () {
|
return Lbryio.getCurrentUser().then(function (user) {
|
||||||
return true;
|
return user;
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}).then(function (isTokenValid) {
|
}).then(function (user) {
|
||||||
if (isTokenValid) {
|
if (user) {
|
||||||
return reject;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _lbryRedux.Lbry.status().then(function (status) {
|
return _lbryRedux.Lbry.status().then(function (status) {
|
||||||
|
@ -827,7 +827,12 @@ Lbryio.authenticate = function () {
|
||||||
|
|
||||||
return reject();
|
return reject();
|
||||||
});
|
});
|
||||||
}).then(Lbryio.getCurrentUser).then(resolve, reject);
|
}).then(function (user) {
|
||||||
|
if (!user) {
|
||||||
|
return Lbryio.getCurrentUser();
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}).then(resolve, reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,17 +110,17 @@ Lbryio.authenticate = () => {
|
||||||
Lbryio.getAuthToken()
|
Lbryio.getAuthToken()
|
||||||
.then(token => {
|
.then(token => {
|
||||||
if (!token || token.length > 60) {
|
if (!token || token.length > 60) {
|
||||||
return false;
|
return [false];
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that token works
|
// check that token works
|
||||||
return Lbryio.getCurrentUser()
|
return Lbryio.getCurrentUser()
|
||||||
.then(() => true)
|
.then(user => user)
|
||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
})
|
})
|
||||||
.then(isTokenValid => {
|
.then(user => {
|
||||||
if (isTokenValid) {
|
if (user) {
|
||||||
return reject;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Lbry.status().then(status => {
|
return Lbry.status().then(status => {
|
||||||
|
@ -137,7 +137,12 @@ Lbryio.authenticate = () => {
|
||||||
return reject();
|
return reject();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(Lbryio.getCurrentUser)
|
.then(user => {
|
||||||
|
if (!user) {
|
||||||
|
return Lbryio.getCurrentUser();
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
})
|
||||||
.then(resolve, reject);
|
.then(resolve, reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue