Implemented authentication with database