ubccpsc / classportal_deprecated

DEPRECATED: ClassPortal instance from 2017.
3 stars 5 forks source link

Odd user state #4

Closed rtholmes closed 8 years ago

rtholmes commented 8 years ago

I'm seeing the same state you were today (e.g., 'Welcome, !').

In the javascript console I see:

jquery.min.js:4 POST http://skaha.cs.ubc.ca:8020/api/loadAdminPortal 500 (Internal Server Error)

While on the server I see:

POST /api/loadAdminPortal
Username: rtholmes | Token: dv5kgbwv441maom1rv2y8ehfr | Admin: true
Params: {}
----------------------------------------------------
<T> 9/15/2016, 5:19:28 AM: requireAdmin| Checking admin status..
<T> 9/15/2016, 5:19:28 AM: requireAdmin| Valid admin field. Continuing to next middleware..
----------------------------------------------------
<T> 9/15/2016, 5:19:28 AM: checkToken| Checking token..
<T> 9/15/2016, 5:19:28 AM: Helper::readFile| Reading file: tokens.json
<T> 9/15/2016, 5:19:28 AM: Helper::readFile| File read success.
<T> 9/15/2016, 5:19:28 AM: checkToken| Error: Tokens do not match (dv5kgbwv441maom1rv2y8ehfr:li87fqe5shhxupby0prsve7b9) Returning..

I wonder if it is because I'm trying logging into two different browsers? This should work, but doest.

rtholmes commented 8 years ago

Note: if I log out and log in again it works. This might have been why you were getting odd behaviour between your phone and presumably the session you started on your laptop.

mksarge commented 8 years ago

Hm, I think these are two separate issues- 1) The problem of logging on when already logged in on another browser/device. What happens is that a new servertoken is generated upon each login and the old one gets overwritten, rendering the first logged-in device in an unusable state (due to its now invalid token) and the second device in a usable state.

To fix this, perhaps we can have tokens.json store multiple servertokens per user, only deleting a token when the logout function is called, instead of overwriting the token upon each new login.

2) The unusable state of my account still seems to be because of the failed attempt to grab my grades file by username. As we discussed, I'll get rid of the username property completely and search by sid instead.

mksarge commented 8 years ago

Closing this; the multiple login issue is covered in #8 , and the grades.json issue was fixed by removing the unnecessary 'username' identifier (grade entries can already be uniquely identified by 'sid').