Refactored how user login status is checked.