Don't double encrypt when updating/add if not exists

This commit is contained in:
Jon Herron 2023-03-07 09:53:19 -05:00
parent ce5969e9ca
commit 0fa44d3d80
2 changed files with 2 additions and 2 deletions

View File

@ -43,7 +43,7 @@ def authentication_callback(
"""Authentication_callback."""
verify_token(request.args.get("token"), force_run=True)
response = request.args["response"]
SecretService().update_secret(
SecretService.update_secret(
f"{service}/{auth_method}", response, g.user.id, create_if_not_exists=True
)
return redirect(

View File

@ -68,9 +68,9 @@ class SecretService:
create_if_not_exists: Optional[bool] = False,
) -> None:
"""Does this pass pre commit?"""
value = cls._encrypt(value)
secret_model = SecretModel.query.filter(SecretModel.key == key).first()
if secret_model:
value = cls._encrypt(value)
secret_model.value = value
db.session.add(secret_model)
try: