Changed the logic of working with authentication status.