implement user login and fix bugs in the Database class