mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-07 03:58:25 -04:00
Refactor ApiKeys.secret and ServiceInboundApi.bearer_token to use the same encryption method and get rid of the duplicate code.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from datetime import datetime
|
||||
|
||||
from app import db, create_uuid
|
||||
from app.authentication.utils import generate_secret
|
||||
from app.dao.dao_utils import transactional, version_class
|
||||
from app.models import ServiceInboundApi
|
||||
|
||||
@@ -11,7 +10,7 @@ from app.models import ServiceInboundApi
|
||||
def save_service_inbound_api(service_inbound_api):
|
||||
service_inbound_api.id = create_uuid()
|
||||
service_inbound_api.created_at == datetime.utcnow()
|
||||
service_inbound_api.bearer_token = generate_secret(service_inbound_api.bearer_token)
|
||||
service_inbound_api.bearer_token = service_inbound_api.bearer_token
|
||||
db.session.add(service_inbound_api)
|
||||
|
||||
|
||||
@@ -21,7 +20,7 @@ def reset_service_inbound_api(service_inbound_api, updated_by_id, url=None, bear
|
||||
if url:
|
||||
service_inbound_api.url = url
|
||||
if bearer_token:
|
||||
service_inbound_api.bearer_token = generate_secret(bearer_token)
|
||||
service_inbound_api.bearer_token = bearer_token
|
||||
service_inbound_api.updated_by_id = updated_by_id
|
||||
service_inbound_api.updated_at = datetime.utcnow()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user