Added support for logging in with legacy hashes.
BTW We really should grab all the password hashing code spread out all over the code and put it in one place.