The fixed example code suffers from a security issue due to passwords being stored unhashed.
Login code should use the password hashing API to store and compare passwords.
Either don't use a login system as an example, or provide a good-to-follow example.