Skip to content

Commit

Permalink
Include CSRF cookie with first GET request
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Aug 5, 2024
1 parent 2563be1 commit e1f23e7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion arches_lingo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
NOCAPTCHA = True
# RECAPTCHA_PROXY = 'http://127.0.0.1:8000'
if DEBUG is True:
SILENCED_SYSTEM_CHECKS = ["captcha.recaptcha_test_key_error"]
SILENCED_SYSTEM_CHECKS += ["captcha.recaptcha_test_key_error"]


# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' #<-- Only need to uncomment this for testing without an actual email server
Expand Down
2 changes: 0 additions & 2 deletions arches_lingo/src/arches_lingo/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function getToken() {
export const login = async (username: string, password: string) => {
const response = await fetch(arches.urls.api_login, {
method: "POST",
credentials: "include",
headers: { "X-CSRFTOKEN": getToken() },
body: JSON.stringify({ username, password }),
});
Expand All @@ -30,7 +29,6 @@ export const login = async (username: string, password: string) => {
export const logout = async () => {
const response = await fetch(arches.urls.api_logout, {
method: "POST",
credentials: "include",
headers: { "X-CSRFTOKEN": getToken() },
});
if (response.ok) {
Expand Down
2 changes: 2 additions & 0 deletions arches_lingo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.shortcuts import render
from django.utils.translation import gettext_lazy as _
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.generic import View

from arches.app.models.models import (
Expand Down Expand Up @@ -204,6 +205,7 @@ def get(self, request):


class LingoRootView(BaseManagerView):
@method_decorator(ensure_csrf_cookie)
def get(self, request, graphid=None, resourceid=None):
context = self.get_context_data(main_script="views/root")
context["page_title"] = _("Lingo")
Expand Down

0 comments on commit e1f23e7

Please sign in to comment.