Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 4be56f3

Browse files
author
Ray Arayilakath
committed
Minor Bug Squashes
1 parent e6e1044 commit 4be56f3

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
let _defaultInitVariables = {
22
username: undefined,
3+
captcha: {
4+
token: undefined
5+
},
36
endpoints: {
47
gql: undefined,
58
restful: undefined,
@@ -20,15 +23,14 @@ module.exports = function(initVariables) {
2023
if(typeof value == 'object') {
2124
for([nestedKey, nestedValue] of Object.entries(value)) {
2225
if(typeof nestedValue != 'string' && typeof nestedValue != 'number') throw new Error(`Invalid type for value of ${nestedKey}.`);
23-
else if(_defaultInitVariables[key][nestedKey]) _defaultInitVariables[key][nestedKey] = nestedValue;
26+
else if(_defaultInitVariables[key][nestedKey] === undefined) _defaultInitVariables[key][nestedKey] = nestedValue;
2427
}
2528
} else {
2629
if(typeof value != 'string' && typeof value != 'number') throw new Error(`Invalid type for value of ${key}.`);
27-
else if(_defaultInitVariables[key]) _defaultInitVariables[key] = value;
30+
else if(_defaultInitVariables[key] === undefined) _defaultInitVariables[key] = value;
2831
}
2932
}
3033
global.initVariables = _defaultInitVariables
31-
console.log(global.initVariables)
3234
} else {
3335
global.initVariables = _defaultInitVariables;
3436
}

src/classes/Login.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
let headers = require('../utils/headers.js');
22
let constants = require('../utils/constants.js');
33

4-
async function _getCookies(user, pass) {
5-
if (user == 'RayhanADev') {
4+
async function _getCookies(username, password) {
5+
if (['RayhanADev'].includes(global.initVariables.username)) {
66
let info = await constants
77
.fetch(constants.login, {
88
method: 'POST',
99
headers,
1010
body: JSON.stringify({
11-
user,
12-
pass
11+
username: username,
12+
password: password,
13+
captcha: global.initVariables.captcha.token,
14+
hCaptchaSiteKey: '7f7c5b9f-8cff-49f3-ab09-5666dca1104b'
1315
})
14-
})
15-
.then(res => {
16-
return res.headers.raw()['Set-Cookie'][1];
17-
});
16+
}).then(res => res.headers.raw()['set-cookie'][1]);
1817

1918
if (!info) {
2019
throw new Error(`Couldn't fetch cookie data.`);
@@ -23,28 +22,28 @@ async function _getCookies(user, pass) {
2322
}
2423
} else {
2524
throw new Error(
26-
`${user} is not whitelisted. Please contact @RayhanADev in ReplTalk to talk about getting added to the whitelist.`
25+
`${global.initVariables.username} is not whitelisted. Please contact @RayhanADev in ReplTalk to talk about getting added to the whitelist.`
2726
);
2827
}
2928
}
3029

3130
class Login {
3231
async withCredentials(password) {
33-
if (['RayhanADev'].contains(global.initVariables.username)) {
32+
if (['RayhanADev'].includes(global.initVariables.username)) {
3433
global.cookies = await _getCookies(global.initVariables.username, password);
3534
} else {
3635
throw new Error(
37-
`${user} is not whitelisted. Please contact @RayhanADev in ReplTalk to talk about getting added to the whitelist.`
36+
`${global.initVariables.username} is not whitelisted. Please contact @RayhanADev in ReplTalk to talk about getting added to the whitelist.`
3837
);
3938
}
4039
}
4140

4241
async withSID(sid) {
43-
if (['RayhanADev'].contains(global.initVariables.username)) {
42+
if (['RayhanADev'].includes(global.initVariables.username)) {
4443
global.cookies = sid;
4544
} else {
4645
throw new Error(
47-
`${user} is not whitelisted. Please contact @RayhanADev in ReplTalk to talk about getting added to the whitelist.`
46+
`${global.initVariables.username} is not whitelisted. Please contact @RayhanADev in ReplTalk to talk about getting added to the whitelist.`
4847
);
4948
}
5049
}

src/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const leaderboard = require('./classes/Leaderboard.js');
77
const languages = require('./classes/Languages.js');
88
const board = require('./classes/Board.js');
99
const notifications = require('./classes/Notifications.js');
10-
const misc = require('./classes/Misc.js')
1110
const custom = require('./classes/Custom.js')
1211

1312
if (!login) throw new Error('Login class not found');
@@ -19,7 +18,6 @@ if (!leaderboard) throw new Error('Leaderboard class not found');
1918
if (!languages) throw new Error('Languages class not found');
2019
if (!board) throw new Error('Board class not found');
2120
if (!notifications) throw new Error('Notifications class not found');
22-
if (!misc) throw new Error('Miscellaneous class not found');
2321
if (!custom) throw new Error('Custom class not found');
2422

2523
module.exports = {
@@ -32,7 +30,6 @@ module.exports = {
3230
Languages: languages.Languages,
3331
Board: board.Board,
3432
Notifications: notifications.Notifications,
35-
Misc: misc.Misc,
3633
CustomDataQuery: custom.CustomDataQuery,
3734
CustomRecursiveQuery: custom.CustomRecursiveQuery
3835
}

0 commit comments

Comments
 (0)