Skip to content

Commit 144479b

Browse files
committed
add: max redirect 5 limit for infinity loops
1 parent 2de39b9 commit 144479b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/miscRequests.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,11 @@ module.exports = {
427427
* @param {string} [location] Auth page location (For france: https://fr.tradingview.com/)
428428
* @returns {Promise<User>} Token
429429
*/
430-
async getUser(session, signature = '', location = 'https://www.tradingview.com/') {
430+
async getUser(session, signature = '', location = 'https://www.tradingview.com/', redirectCount = 0) {
431+
if (redirectCount > 5) {
432+
throw new Error('Too many redirects - invalid session/signature');
433+
}
434+
431435
const { data, headers } = await axios.get(location, {
432436
headers: {
433437
cookie: genAuthCookies(session, signature),
@@ -459,7 +463,7 @@ module.exports = {
459463
}
460464

461465
if (headers.location !== location) {
462-
return this.getUser(session, signature, headers.location);
466+
return this.getUser(session, signature, headers.location, redirectCount + 1);
463467
}
464468

465469
throw new Error('Wrong or expired sessionid/signature');

0 commit comments

Comments
 (0)