mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
code review feedback
This commit is contained in:
@@ -25,9 +25,9 @@ def save_model_api_key(api_key):
|
|||||||
def expire_api_key(service_id, api_key_id):
|
def expire_api_key(service_id, api_key_id):
|
||||||
api_key = (
|
api_key = (
|
||||||
db.session.execute(
|
db.session.execute(
|
||||||
select(ApiKey).filter_by(id=api_key_id, service_id=service_id)
|
select(ApiKey).where(ApiKey.id==api_key_id, ApiKey.service_id==service_id)
|
||||||
)
|
)
|
||||||
.scalars()
|
#.scalars()
|
||||||
.one()
|
.one()
|
||||||
)
|
)
|
||||||
api_key.expiry_date = utc_now()
|
api_key.expiry_date = utc_now()
|
||||||
@@ -36,9 +36,13 @@ def expire_api_key(service_id, api_key_id):
|
|||||||
|
|
||||||
def get_model_api_keys(service_id, id=None):
|
def get_model_api_keys(service_id, id=None):
|
||||||
if id:
|
if id:
|
||||||
return db.session.execute(
|
return (
|
||||||
select(ApiKey).where(id=id, service_id=service_id, expiry_date=None)
|
db.session.execute(
|
||||||
).one()
|
select(ApiKey).where(ApiKey.id==id, ApiKey.service_id==service_id, ApiKey.expiry_date==None)
|
||||||
|
)
|
||||||
|
#.scalars()
|
||||||
|
.one()
|
||||||
|
)
|
||||||
seven_days_ago = utc_now() - timedelta(days=7)
|
seven_days_ago = utc_now() - timedelta(days=7)
|
||||||
return (
|
return (
|
||||||
db.session.execute(
|
db.session.execute(
|
||||||
@@ -59,9 +63,13 @@ def get_unsigned_secrets(service_id):
|
|||||||
"""
|
"""
|
||||||
This method can only be exposed to the Authentication of the api calls.
|
This method can only be exposed to the Authentication of the api calls.
|
||||||
"""
|
"""
|
||||||
api_keys = db.session.execute(
|
api_keys = (
|
||||||
select(ApiKey).where(service_id=service_id, expiry_date=None)
|
db.session.execute(
|
||||||
).all()
|
select(ApiKey).where(ApiKey.service_id==service_id, ApiKey.expiry_date==None)
|
||||||
|
)
|
||||||
|
# .scalars()
|
||||||
|
.all()
|
||||||
|
)
|
||||||
keys = [x.secret for x in api_keys]
|
keys = [x.secret for x in api_keys]
|
||||||
return keys
|
return keys
|
||||||
|
|
||||||
@@ -70,7 +78,9 @@ def get_unsigned_secret(key_id):
|
|||||||
"""
|
"""
|
||||||
This method can only be exposed to the Authentication of the api calls.
|
This method can only be exposed to the Authentication of the api calls.
|
||||||
"""
|
"""
|
||||||
api_key = db.session.execute(
|
api_key = (
|
||||||
select(ApiKey).where(id=key_id, expiry_date=None)
|
db.session.execute(select(ApiKey).where(ApiKey.id==key_id, ApiKey.expiry_date==None))
|
||||||
).one()
|
#.scalars()
|
||||||
|
.one()
|
||||||
|
)
|
||||||
return api_key.secret
|
return api_key.secret
|
||||||
|
|||||||
Reference in New Issue
Block a user