alchemy flush and save functions updated
This commit is contained in:
@@ -161,9 +161,8 @@ class AuthModule(PasswordModule):
|
||||
found_user.password_expiry_begins = str(system_arrow.now())
|
||||
found_user.hash_password = new_password_dict.get("password")
|
||||
found_user.password_token = "" if found_user.password_token else ""
|
||||
found_user.save()
|
||||
query_engine.refresh_password_history_via_user(payload=history_dict)
|
||||
return
|
||||
return found_user.save()
|
||||
|
||||
@staticmethod
|
||||
def reset_password_token(found_user):
|
||||
|
||||
@@ -79,7 +79,6 @@ class MongoQueryIdentity:
|
||||
hashed_password = payload.password_add.get("password")
|
||||
for password_in_history in password_history_list:
|
||||
if str(password_in_history.get("password")) == str(hashed_password):
|
||||
print('Password already used. Please enter a new password that you have not used last 3 times.')
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="Password already used. Please enter a new password that you have not used last 3 times.",
|
||||
@@ -89,7 +88,7 @@ class MongoQueryIdentity:
|
||||
password_history_list.pop(0)
|
||||
|
||||
password_history_list.append(payload.password_add)
|
||||
self.mongo_engine.update(
|
||||
return self.mongo_engine.update(
|
||||
match=payload.user_uu_id,
|
||||
payload={
|
||||
"password_history": password_history_list,
|
||||
@@ -98,7 +97,6 @@ class MongoQueryIdentity:
|
||||
},
|
||||
field="user_uu_id",
|
||||
)
|
||||
return True
|
||||
|
||||
def get_password_history_via_user(self, user_uu_id):
|
||||
self.use_collection("PasswordHistory")
|
||||
|
||||
@@ -61,7 +61,6 @@ class MongoQuery:
|
||||
return self.table.insert_many(documents=[payload])
|
||||
|
||||
def update(self, match, payload, field: str = "id"):
|
||||
print('update', match, payload, field)
|
||||
if field == "id":
|
||||
filter_ = {"_id": ObjectId(match)}
|
||||
self.table.update_one(filter=filter_, update={"$set": payload})
|
||||
|
||||
@@ -24,11 +24,11 @@ class FilterAttributes:
|
||||
FilterModel = ListOptions
|
||||
|
||||
def flush(self):
|
||||
from fastapi import status
|
||||
"""Flush the current session."""
|
||||
try:
|
||||
self.__session__.add(self)
|
||||
self.__session__.flush()
|
||||
return self
|
||||
except SQLAlchemyError as e:
|
||||
self.raise_http_exception(
|
||||
status_code="HTTP_400_BAD_REQUEST",
|
||||
@@ -47,6 +47,7 @@ class FilterAttributes:
|
||||
"""Saves the updated model to the current entity db."""
|
||||
try:
|
||||
cls.__session__.commit()
|
||||
return cls
|
||||
except SQLAlchemyError as e:
|
||||
cls.raise_http_exception(
|
||||
status_code="HTTP_400_BAD_REQUEST",
|
||||
|
||||
Reference in New Issue
Block a user