Skip to content

Commit

Permalink
Set dockerfile to use jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
berrydenhartog committed Aug 21, 2024
1 parent 887a333 commit 981651b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ COPY ./poetry.lock ./pyproject.toml ./
COPY ./package-lock.json ./package.json .nvmrc ./
COPY ./webpack.config.js ./webpack.config.prod.js ./
COPY ./tsconfig.json ./eslint.config.mjs ./
COPY ./jest.config.ts ./

RUN mkdir -p $NVM_DIR && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash

Expand Down
2 changes: 2 additions & 0 deletions amt/api/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def TemplateResponse( # pyright: ignore [reportIncompatibleMethodOverride]

if context is None:
context = {}

context["csrftoken"] = request.state.csrftoken

return super().TemplateResponse(request, name, context, status_code, headers, media_type, background)

def Redirect(self, request: Request, url: str) -> HTMLResponse:
Expand Down
2 changes: 2 additions & 0 deletions amt/middleware/csrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def _include_request(self, request: Request) -> bool:

async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response:
signed_token = ""

if self._include_request(request):
request.state.csrftoken = ""

if request.method in self.safe_methods:
csrf_token, signed_token = self.csrf_protect.generate_csrf_tokens()
logger.debug(f"generating tokens: csrf_token={csrf_token}, signed_token={signed_token}")
Expand Down

0 comments on commit 981651b

Please sign in to comment.