Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a bug in main: self.loggedIn : 113 - leading to Cannot read property 'reminders' of undefined #83

Open
paulroth3d opened this issue Oct 2, 2023 · 1 comment

Comments

@paulroth3d
Copy link

TLDR; @MauriceConrad - can you please release a new version - as there is a bug on main.js:113 that is fixed in the repo - BUT NOT if anyone npm installs..


There is a bug in main.js:113

it seems it is FIXED in the repository, BUT NOT IN npm.

This is what you get on line 113 if you install apple-icloud

npm install --save apple-icloud

look at node_modules/apple-icloud/main.js, and you get this:

      self.loggedIn = (function() {
        //console.log(self.auth.cookies.length > 0, !!self.auth.token, self.account != {}, self.username === username);
        return (self.auth.cookies.length > 0 && self.auth.token && self.account != {} && username ? (self.username === username) : true);
      })();

note the final condition: && username ? (self.username === username) : true

this is wrong and needs to be: && (username ? (self.username === username) : false));

(missing the parentheses around the check - bypassing the && operator, and almost always returning true)

This appears fixed in the git repository

https://github.com/MauriceConrad/iCloud-API/blob/master/main.js#L115


This is actually the source of a NUMBER of issues:

#64
#71
#53
#47

and many others.

These - and many others - all come from myCloud.account being an empty object, and therefore none of the apis can be called.

The reason it is empty is because self.loggedIn is setting to true, and therefore the self.login on line 162 never fires.

Could you please release a new version to npm?

@paulroth3d
Copy link
Author

Otherwise, for anyone else running into this,
look in the node_modules/apple-icloud/main.js

and change this:

      // Now, validate the session with checking for important aspects that show that the session can be used to get data (e.g. there need to be a token, some cookies and account info)
      self.loggedIn = (function() {
        //console.log(self.auth.cookies.length > 0, !!self.auth.token, self.account != {}, self.username === username);
        return (self.auth.cookies.length > 0 && self.auth.token && self.account != {} && username ? (self.username === username) : true);
      })();

into this:

      // Now, validate the session with checking for important aspects that show that the session can be used to get data (e.g. there need to be a token, some cookies and account info)
      self.loggedIn = (function() {
        //console.log(self.auth.cookies.length > 0, !!self.auth.token, self.account != {}, self.username === username);
        return (self.auth.cookies.length > 0 && self.auth.token && self.account != {} && username ? ((self.username === username) : false));
      })();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant