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

Commit e6e1044

Browse files
author
Ray Arayilakath
committed
Completely Scrap Login Class and Start Fresh
1 parent 8df6da6 commit e6e1044

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/classes/Login.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ let constants = require('../utils/constants.js');
33

44
async function _getCookies(user, pass) {
55
if (user == 'RayhanADev') {
6-
let info = await variables
7-
.fetch(variables.login, {
6+
let info = await constants
7+
.fetch(constants.login, {
88
method: 'POST',
99
headers,
1010
body: JSON.stringify({
@@ -13,7 +13,7 @@ async function _getCookies(user, pass) {
1313
})
1414
})
1515
.then(res => {
16-
return res.headers.raw()['set-cookie'][1];
16+
return res.headers.raw()['Set-Cookie'][1];
1717
});
1818

1919
if (!info) {
@@ -23,25 +23,28 @@ async function _getCookies(user, pass) {
2323
}
2424
} else {
2525
throw new Error(
26-
`${user} is not whitelisted. Please contact @RayhanADev in Repl.it to talk about getting added to the whitelist.`
26+
`${user} is not whitelisted. Please contact @RayhanADev in ReplTalk to talk about getting added to the whitelist.`
2727
);
2828
}
2929
}
3030

3131
class Login {
32-
constructor(username, password) {
33-
this.username = username;
34-
this.password = password;
32+
async withCredentials(password) {
33+
if (['RayhanADev'].contains(global.initVariables.username)) {
34+
global.cookies = await _getCookies(global.initVariables.username, password);
35+
} else {
36+
throw new Error(
37+
`${user} is not whitelisted. Please contact @RayhanADev in ReplTalk to talk about getting added to the whitelist.`
38+
);
39+
}
3540
}
36-
37-
async account() {
38-
let user = this.username;
39-
let pass = this.password;
40-
if (user == 'RayhanADev') {
41-
global.cookies = await _getCookies(user, pass);
41+
42+
async withSID(sid) {
43+
if (['RayhanADev'].contains(global.initVariables.username)) {
44+
global.cookies = sid;
4245
} else {
4346
throw new Error(
44-
`${user} is not whitelisted. Please contact @RayhanADev in Repl.it to talk about getting added to the whitelist.`
47+
`${user} is not whitelisted. Please contact @RayhanADev in ReplTalk to talk about getting added to the whitelist.`
4548
);
4649
}
4750
}

0 commit comments

Comments
 (0)