Login function updates: upsert_user, change_username/change_password