ubccpsc / classportal_deprecated

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

auth error changed to return 401 and logout user #27

Closed simonhowey closed 7 years ago

simonhowey commented 7 years ago

figured you wouldn't want everyone logged out if the api went down

rtholmes commented 7 years ago

@Simonah88 thanks for the PR. Can you remind me the situation that leads to this code being needed again?

simonhowey commented 7 years ago

I had logged in early in the semester and never logged out, I think at some point my token became invalid. When visiting the class portal the default view is the student portal and it only reroutes you if you don't have any token but doesn't check against a bad token.

You can reproduce with: localStorage.token = "s"

in the console and refresh.

You get:

image

It isn't very clear that this is the result of an authentication error

rtholmes commented 7 years ago

Gotcha. One question, just tapping logout and login seems to fix this right now, does this patch do the same thing, or does it just force the logout?

simonhowey commented 7 years ago

Yes tapping log in and log out does fix it. Client side the code is identical to your logout buttons success/failure callbacks but it doesn't do the AJAX logout request.

Are you hinting that I should have just used the logout code that is already there? :)

rtholmes commented 7 years ago

No, I was just wondering if it should automatically do the login at the same time if it encounters this not-unusual condition. But at least this will keep things from looking inconsistent. Thanks again for the PR.