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

Commit f8b329e

Browse files
authored
Create Login.js
1 parent bc8562d commit f8b329e

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

src/classes/Login.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
let headers = require('../utils/headers.js');
2+
let variables = require('../utils/variables.js');
3+
4+
async function _getCookies(user, pass) {
5+
if (user == 'RayhanADev') {
6+
let info = await variables
7+
.fetch('https://repl.it/login', {
8+
method: 'POST',
9+
headers,
10+
body: JSON.stringify({
11+
user,
12+
pass
13+
})
14+
})
15+
.then(res => {
16+
return res.headers.raw()['set-cookie'][1];
17+
});
18+
19+
if (!info) {
20+
throw new Error(`Couldn't fetch cookie data.`);
21+
} else {
22+
return info;
23+
}
24+
} else {
25+
throw new Error(
26+
`${user} is not whitelisted. Please contact @RayhanADev in Repl.it to talk about getting added to the whitelist.`
27+
);
28+
}
29+
}
30+
31+
class Login {
32+
constructor(username, password) {
33+
this.username = username;
34+
this.password = password;
35+
}
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);
42+
} else {
43+
throw new Error(
44+
`${user} is not whitelisted. Please contact @RayhanADev in Repl.it to talk about getting added to the whitelist.`
45+
);
46+
}
47+
}
48+
}
49+
50+
module.exports = {
51+
Login: Login
52+
};

0 commit comments

Comments
 (0)