add user authentication from database and fix bug