simplyGits / MagisterJS

A JavaScript implementation of the Magister 6 API.
http://simplyGits.github.io/MagisterJS/
GNU Lesser General Public License v3.0
38 stars 13 forks source link

login fails often with username/password #91

Open gruijter opened 5 years ago

gruijter commented 5 years ago

I do a login 24/7, once an hour, using username/password, at three different schools. For one school the login fails around once every 3 to 4 times. This happens in the test password part: https://github.com/simplyGits/MagisterJS/blob/017f475287b95405702c031fd46f0d55cdb10d10/src/magister.js#L458

Error: InvalidUsernameOrPassword at /node_modules/magister.js/lib/magister.js:556:11 at Generator.next () at step (/node_modules/magister.js/lib/magister.js:132:191) at /node_modules/magister.js/lib/magister.js:132:361 at at process._tickCallback (internal/process/next_tick.js:189:7)

netlob commented 5 years ago

What happens when you do the login from the command line a couple times after each other? (Without changing any code)

gruijter commented 5 years ago

then same behaviour. Might be coincidence during my trial, but first login succeeded. Then 10 seconds later I get a timeout on login: Error: FetchError: network timeout at: https://accounts.magister.net/challenge/password then third time I get Error: InvalidUsernameOrPassword then fourth time succeeds again, and the same cycle of failure types repeat themselves.

So it seems to go from success > timeout on challenge password > invalid usernameOrPassword

gruijter commented 5 years ago

Weird, when I pass the token from the last valid login (in stead of username/password) I seem to get a valid login, but the profileInfo = null.

Trying to login after that with username/password results in invalid usernameOrPassword everytime. And after some minutes waiting, I can login again with username/password.

lieuwex commented 5 years ago

The issue for that token problem is #90

netlob commented 5 years ago

Weird, when I pass the token from the last valid login (in stead of username/password) I seem to get a valid login, but the profileInfo = null.

But can you retrieve any other data such as grades and appointments if you login with a token?

I can't cause it gives an error while retrieving the privileges from the login, cause they're null

gruijter commented 5 years ago

Could you re-open this issue pls @lieuwex?

lieuwex commented 5 years ago

Oh woops this shouldn't have been closed indeed.

gruijter commented 5 years ago

So I installed alpha4, and retested the logging in behaviour.

I now made a scheme where I still login every hour to the three different schools/students, and retrieve some information (grades and lessons mostly). I seperated the time between the three schools/students 10 minutes apart. If I have a token, I will first try to login with the token. If that fails I will try to login with username/password as fallback.

I notice from my logging that when using the token, it also often fails to login (once every 3 to 4 times). This happens for multiple schools. The behaviour of logging in with username/password seems to be the same: it fails every 3 to 4 times.

In short: the login problem still persists. It seems to fail randomly in about 25-35 % of the attempts. This goes for both the username/password method, as for the token method.

idiidk commented 5 years ago

@gruijter that the token fails could be because it expires after some time. Don’t know why the username / password login fails tho. When testing I logged in with and without a token like 2 times a minute and didn’t experience any issues. When I’m home I’ll try to replicate the issue but I can’t really promise anything.

gruijter commented 5 years ago

@idiidk You might be correct on the token expiration. When looking at my logs so far it seems to fail the second hour after a login. So the token seems to expire after one hour, two hours at most. I think the token handling deserves a seperate issue/feauture request :)

Concerning the failed login: This only happens at one of the three schools, and seems to occur random. I get the following message:

FetchError: network timeout at: https://accounts.magister.net/challenge/password at Timeout. (/node_modules/node-fetch/lib/index.js:1437:13) at ontimeout (timers.js:498:11) at tryOnTimeout (timers.js:323:5) at Timer.listOnTimeout (timers.js:290:5) message: 'network timeout at: https://accounts.magister.net/challenge/password', type: 'request-timeout