Completed login code.