Moved login code to ORM