OpenChirp / website

Angular 7 based web-frontend for OpenChirp.
3 stars 6 forks source link

Website detect logout status #150

Open linux4life798 opened 5 years ago

linux4life798 commented 5 years ago

The login page should be presented (with auto-redirect) when your login token has expired and you are trying to access some resource. Currently, an error is just displayed and you have to find some way to get to the main page to login.

Two problem scenarios where this occurs: 1) When your cookie has expired and you try to refresh the page on a device. An annoying error is displayed and there is no easy way to re-login. 2) When you click a link to a device and your current web browser is not logged in. The same annoying error is shown without a way to login.

hi-liang commented 5 years ago

Currently the redirects to home on each component (device, location, etc) are one-off error handlers based on subscription response of their respective getter requests (e.g. getDevice()). Example:

https://github.com/OpenChirp/website/blob/51243f4c07cc4d8e91b6074af3755b3f0f2fa1f0/src/app/components/devices/device.component.ts#L102

This should be handled at a much lower level. Unfortunately each of the services have (copies of) their own error handlers, e.g. https://github.com/OpenChirp/website/blob/51243f4c07cc4d8e91b6074af3755b3f0f2fa1f0/src/app/services/device.service.ts#L229

TLDR: All of this should be refactored so at lowest level possible a 401 error response leads to popup of the login component.