mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
code review feedback
This commit is contained in:
@@ -25,9 +25,11 @@ 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).where(ApiKey.id==api_key_id, ApiKey.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()
|
||||||
@@ -38,9 +40,13 @@ def get_model_api_keys(service_id, id=None):
|
|||||||
if id:
|
if id:
|
||||||
return (
|
return (
|
||||||
db.session.execute(
|
db.session.execute(
|
||||||
select(ApiKey).where(ApiKey.id==id, ApiKey.service_id==service_id, ApiKey.expiry_date==None)
|
select(ApiKey).where(
|
||||||
|
ApiKey.id == id,
|
||||||
|
ApiKey.service_id == service_id,
|
||||||
|
ApiKey.expiry_date == None, # noqa
|
||||||
|
)
|
||||||
)
|
)
|
||||||
#.scalars()
|
# .scalars()
|
||||||
.one()
|
.one()
|
||||||
)
|
)
|
||||||
seven_days_ago = utc_now() - timedelta(days=7)
|
seven_days_ago = utc_now() - timedelta(days=7)
|
||||||
@@ -65,7 +71,9 @@ def get_unsigned_secrets(service_id):
|
|||||||
"""
|
"""
|
||||||
api_keys = (
|
api_keys = (
|
||||||
db.session.execute(
|
db.session.execute(
|
||||||
select(ApiKey).where(ApiKey.service_id==service_id, ApiKey.expiry_date==None)
|
select(ApiKey).where(
|
||||||
|
ApiKey.service_id == service_id, ApiKey.expiry_date == None # noqa
|
||||||
|
)
|
||||||
)
|
)
|
||||||
# .scalars()
|
# .scalars()
|
||||||
.all()
|
.all()
|
||||||
@@ -79,8 +87,10 @@ 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 = (
|
api_key = (
|
||||||
db.session.execute(select(ApiKey).where(ApiKey.id==key_id, ApiKey.expiry_date==None))
|
db.session.execute(
|
||||||
#.scalars()
|
select(ApiKey).where(ApiKey.id == key_id, ApiKey.expiry_date == None) # noqa
|
||||||
|
)
|
||||||
|
# .scalars()
|
||||||
.one()
|
.one()
|
||||||
)
|
)
|
||||||
return api_key.secret
|
return api_key.secret
|
||||||
|
|||||||
Reference in New Issue
Block a user