Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.5 KB

hw2-3-answer.md

File metadata and controls

48 lines (34 loc) · 1.5 KB

Homework 2.3

Description complète

Pièces jointes

Problème

We have removed two pymongo statements from userDAO.py and marked the area where you need to work with XXX. You should not need to touch any other code. The pymongo statements that you are going to add will add a new user upon sign-up and validate a login by retrieving the right user document.

Résolution

Validation du login:

class UserDAO:
    ...

    def validate_login(self, username, password):
        ...
        try:
            # XXX HW 2.3 Students Work Here
            user = self.users.find_one( { '_id': username})
        ...

Ajout d'un utilisateur:

    def add_user(self, username, password, email):
        ...
        try:
            # XXX HW 2.3 Students work here
            self.users.insert( user)
        ...

Réponse

(venv) course-m101p/hw2-3 $ python validate.py
Welcome to the HW 2.3 validation tester
Trying to create a test user  aqOmuEl
Found the test user  aqOmuEl  in the users collection
User creation successful. 
Trying to login for test user  aqOmuEl
User login successful.
Validation Code is  jkfds9834j98fnm39njf0920fn2

--> jkfds9834j98fnm39njf0920fn2