add reset password
This commit is contained in:
@@ -17,7 +17,7 @@ from layercake.dynamodb import (
|
||||
)
|
||||
from layercake.funcs import pick
|
||||
|
||||
from .authorizer_middleware import User
|
||||
from .authentication_middleware import User
|
||||
|
||||
YEAR_DAYS = 365
|
||||
LOG_RETENTION_DAYS = YEAR_DAYS * 2
|
||||
@@ -29,14 +29,14 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
action : str
|
||||
action: str
|
||||
The identifier for the audit log action.
|
||||
collect : DynamoDBCollection
|
||||
collect: DynamoDBCollection
|
||||
The collection instance used to persist the audit log data.
|
||||
audit_attrs : tuple of str, optional
|
||||
audit_attrs: tuple of str, optional
|
||||
A tuple of attribute names to extract from the response body for logging.
|
||||
These represent the specific fields to include in the audit log.
|
||||
retention_days : int or None, optional
|
||||
retention_days: int or None, optional
|
||||
The number of days the log is retained on the server.
|
||||
If None, no time-to-live (TTL) will be applied.
|
||||
"""
|
||||
@@ -64,10 +64,13 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
|
||||
ip_addr = req_context.http.source_ip
|
||||
response = next_middleware(app)
|
||||
|
||||
print(app.context['_route'])
|
||||
|
||||
# Successful response
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status#successful_responses
|
||||
if 200 <= response.status_code < 300 and user:
|
||||
now_ = now()
|
||||
author = pick(('id', 'name'), dict(user))
|
||||
data = (
|
||||
pick(self.audit_attrs, extract_event_from_common_models(response.body))
|
||||
if response.is_json()
|
||||
@@ -89,7 +92,7 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
|
||||
action=self.action,
|
||||
data=data,
|
||||
ip=ip_addr,
|
||||
author='himself',
|
||||
author=author,
|
||||
ttl=retention_days,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user