Refactored Login and Temporary User Creation Code