SchoolUtils / WebUntis

JavaScript WebUntis API Client
https://webuntis.noim.me/
MIT License
166 stars 21 forks source link

Logical error in v2? #89

Closed DEVTomatoCake closed 2 years ago

DEVTomatoCake commented 2 years ago

Just updated to v2 and well, it apparently doesnt like the server anymore:

Error: Failed to login. Server didn't return a session id.
    at WebUntisQR._otpLogin (/home/container/node_modules/webuntis/dist/webuntis.js:648:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async WebUntisQR.login (/home/container/node_modules/webuntis/dist/webuntis.js:748:12)

Caused by (compiled) L648:

if (response.headers && response.headers["set-cookie"] && this._getCookieFromSetCookie(response.headers["set-cookie"]))
      throw new Error("Failed to login. Server didn't return a session id.");

But the last check in the if clause doesnt make sense, it should have a ! in front of it - esp as the next line uses it:

const sessionId = this._getCookieFromSetCookie(response.headers["set-cookie"]);

Added the ! in my code and its working completely fine then 🤷

Uncompiled: https://github.com/SchoolUtils/WebUntis/blob/479c60b34702b943d48c1787d26961351192d167/index.js#L862

TheNoim commented 2 years ago

You are right. This was a mistake.

TheNoim commented 2 years ago

Try v2.0.1