{"action":"created","issue":{"url":"https://api.github.com/repos/concept-to-clinic/concept-to-clinic/issues/114","repository_url":"https://api.github.com/repos/concept-to-clinic/concept-to-clinic","labels_url":"https://api.github.com/repos/concept-to-clinic/concept-to-clinic/issues/114/labels{/name}","comments_url":"https://api.github.com/repos/concept-to-clinic/concept-to-clinic/issues/114/comments","events_url":"https://api.github.com/repos/concept-to-clinic/concept-to-clinic/issues/114/events","html_url":"https://github.com/concept-to-clinic/concept-to-clinic/issues/114","id":257682458,"number":114,"title":"Always pass CSRF tokens when posting with jQuery","user":{"login":"WGierke","id":6676439,"avatar_url":"https://avatars1.githubusercontent.com/u/6676439?v=4","gravatar_id":"","url":"https://api.github.com/users/WGierke","html_url":"https://github.com/WGierke","followers_url":"https://api.github.com/users/WGierke/followers","following_url":"https://api.github.com/users/WGierke/following{/other_user}","gists_url":"https://api.github.com/users/WGierke/gists{/gist_id}","starred_url":"https://api.github.com/users/WGierke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WGierke/subscriptions","organizations_url":"https://api.github.com/users/WGierke/orgs","repos_url":"https://api.github.com/users/WGierke/repos","events_url":"https://api.github.com/users/WGierke/events{/privacy}","received_events_url":"https://api.github.com/users/WGierke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-09-14T11:15:36Z","updated_at":"2017-09-20T16:00:37Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"As stated [here](https://github.com/concept-to-clinic/concept-to-clinic/pull/101#discussion_r138825291), it would be nice to automatically add the current page's CSRF token to a POST request by jQuery.\r\n\r\n## Expected Behavior\r\nWhen posting to the API, one is not required to always manually parse the CSRF token from the current page and send it to the backend.\r\n\r\n## Current Behavior\r\nOne is supposed to grap the token from the page every time one wants to post something:\r\n```\r\nupdate: function(nodule) {\r\n        this.$http.post(nodule.url + \"update\",\r\n          { csrfmiddlewaretoken: $(\"input[name=csrfmiddlewaretoken]\").val(),\r\n            lung_orientation: $(\"select[name=lung_orientation]\").val()\r\n          }).then(function(response) {\r\n          console.log(response);\r\n          }\r\n```\r\nWe don't want to always manually add `csrfmiddlewaretoken: $(\"input[name=csrfmiddlewaretoken]\").val()`.\r\n\r\n## Possible Solution\r\nUse one of jQuerys global AJAX handlers like [.ajaxSend()](https://api.jquery.com/ajaxSend/).\r\n\r\n## Checklist before submitting\r\n- [X] I have searched through the other currently open issues and am confident this is not a duplicate of an existing bug\r\n- [X] I provided a **minimal code snippet** or list of steps that reproduces the bug.\r\n- [X] I filled out all the relevant sections of this template\r\n"},"comment":{"url":"https://api.github.com/repos/concept-to-clinic/concept-to-clinic/issues/comments/330899101","html_url":"https://github.com/concept-to-clinic/concept-to-clinic/issues/114#issuecomment-330899101","issue_url":"https://api.github.com/repos/concept-to-clinic/concept-to-clinic/issues/114","id":330899101,"user":{"login":"isms","id":1284973,"avatar_url":"https://avatars3.githubusercontent.com/u/1284973?v=4","gravatar_id":"","url":"https://api.github.com/users/isms","html_url":"https://github.com/isms","followers_url":"https://api.github.com/users/isms/followers","following_url":"https://api.github.com/users/isms/following{/other_user}","gists_url":"https://api.github.com/users/isms/gists{/gist_id}","starred_url":"https://api.github.com/users/isms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isms/subscriptions","organizations_url":"https://api.github.com/users/isms/orgs","repos_url":"https://api.github.com/users/isms/repos","events_url":"https://api.github.com/users/isms/events{/privacy}","received_events_url":"https://api.github.com/users/isms/received_events","type":"User","site_admin":false},"created_at":"2017-09-20T16:00:37Z","updated_at":"2017-09-20T16:00:37Z","author_association":"CONTRIBUTOR","body":"Hi @WGierke, looks like we have a way forward with the jQuery issues (i.e. using Vue instead) and that the [CSRF discussion](https://github.com/concept-to-clinic/concept-to-clinic/pull/101#issuecomment-330028424) is separate.\r\n\r\nAny objections to closing?"}}
{"actor":{"display_login":"isms"}}