Browse Source

fix logUsingCookie

* it seems that the site only cares about the cookie `session_id`
* when checking if the user is authenticated the cookie jar was not being used
elisha464 4 years ago
parent
commit
fa4c68c239
1 changed files with 2 additions and 4 deletions
  1. 2 4
      src/my_request.ts

+ 2 - 4
src/my_request.ts

@@ -110,7 +110,7 @@ function checkIfUserIsAuth(config: IConfig, done: (err: Error) => void): void
    */
   const url = 'http://www.crunchyroll.com/';
 
-  cloudscraper.get({gzip: true, uri: url}, (err: Error, rep: string, body: string) =>
+  cloudscraper.get({gzip: true, uri: url, jar: j}, (err: Error, rep: string, body: string) =>
   {
     if (err)
     {
@@ -338,9 +338,7 @@ function authenticate(config: IConfig, done: (err: Error) => void)
     }
     else if (config.logUsingCookie)
     {
-      j.setCookie(request.cookie('c_userid=' + config.crUserId + '; Domain=crunchyroll.com; HttpOnly; hostOnly=false;'),
-                  CR_COOKIE_DOMAIN);
-      j.setCookie(request.cookie('c_userkey=' + config.crUserKey + '; Domain=crunchyroll.com; HttpOnly; hostOnly=false;'),
+      j.setCookie(request.cookie('session_id=' + config.crSessionId + '; Domain=crunchyroll.com; HttpOnly; hostOnly=false;'),
                   CR_COOKIE_DOMAIN);
 
       checkIfUserIsAuth(config, (errCheckAuth2) =>