Fix auto-logout bug