Make the login check into a separate file