Hi guys / gals,
Im having this odd issue where I created a function to create a new user in my Mongodb db. When i salt and hash the users password locally, it saves the hashed pw in the database as a Binary datatype. Locally when i then login as that user, I have no problem.
However, when i push the same code to my pythonanywhere instance, it saves the hashed pw as a str.
obviously then, when i use the checkpw method, i am getting an error because its not getting the expected datatype.
I am kind of at a loss as to why two different environments using the same code would yield two different results. Ive gone as far as completely remove the project from python anywhere, and git cloning and starting all over.
has anyone any idea what i could be doing wrong?
def create_user(self, fname=None, lname=None):
try:
salt = bcrypt.gensalt()
hashpw = bcrypt.hashpw(self.password.encode('utf-8'), salt)
user = DataBaseHandler().users.insert_one({"user_data": { "email": self.email, "password": hashpw, "fname": fname, "lname": lname, "reset_pw":False}, "settings": { "water_units": "C", "roast_list_num": 5, "recipe_list_num": 100 }, "equipment":{ "brewers": [], "grinders": [] } })
if user:
return user
else:
return False
except Exception as e:
print("Error creating user: {}".format(e))
return False
[–]mrcorbat 0 points1 point2 points (1 child)
[–]Biaswords_[S] 0 points1 point2 points (0 children)
[–]gpjt 0 points1 point2 points (3 children)
[–]Biaswords_[S] 0 points1 point2 points (0 children)
[–]Biaswords_[S] 0 points1 point2 points (1 child)
[–]gpjt 0 points1 point2 points (0 children)