Fix API authentication error handling
- Don't redirect to home page on failed login if a guest user is already logged in.
- Don't remove current guest authentication when a login fails.
- Logout, redirect to login page and show notification for other cases where requests fail with status 401.
Fixes: #633 (closed), #652 (closed)