refactor AJAX sign in and sign in after timeout