Added login function. Tested and working.