11let headers = require ( '../utils/headers.js' ) ;
22let 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
3130class 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 }
0 commit comments