Ticket- User management

   """
   Ticket: User Management
   For this ticket, you will need to implement the following six methods:

 - get_user
 - add_user
 - login_user
 - logout_user
 - get_user_session
 - delete_user

 You can find these methods below this docstring. Make sure to read the comments
 to better understand the task.
 """**strong text**

 def get_user(email):

Given an email, returns a document from the `users` collection.

# TODO: User Management
# Retrieve the user document corresponding with the user's email.
return db.users.find_one({ "email": email })

def add_user(name, email, hashedpw):

Given a name, email and password, inserts a document with those credentials
to the `users` collection.
"""

"""
Ticket: Durable Writes

Please increase the durability of this method by using a non-default write
concern with ``insert_one``.
"""

try:
    # TODO: User Management
    # Insert a user with the "name", "email", and "password" fields.
    # TODO: Durable Writes
    # Use a more durable Write Concern for this operation.
    db.users.update_one({"email": email},{"$set": {"name": name,"email": email,"password": hashedpw}}, upsert=True)
    return {"success": True}
except DuplicateKeyError:
    return {"error": "A user with the given email already exists."}

Hey guys please check my code i am getting trouble in this or just anyone tell the proper code which i will execute and pass the ticket.
Thank you i will wait for your reply…
Shadab…

What trouble do you get? Compile error, exception, wrong results? Please post any error message you are getting. A screenshot of what you are doing that shows the issue you are getting is very helpful.

1 Like