summaryrefslogtreecommitdiff
path: root/web-ui/src/common/util.js
diff options
context:
space:
mode:
authorAnike Arni <aarni@thoughtworks.com>2017-03-30 17:23:41 -0300
committerAnike Arni <aarni@thoughtworks.com>2017-03-31 18:29:48 -0300
commit7be03150100d319c6d373241f614a29b374cb74d (patch)
tree90a553dfa0b6f119300a00e6ef02788923035e5c /web-ui/src/common/util.js
parentf40808a147d1135e8bbee6d78306a598cf5ca647 (diff)
[#935] Submits user recovery code to new endpoint
with @deniscostadsc
Diffstat (limited to 'web-ui/src/common/util.js')
-rw-r--r--web-ui/src/common/util.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/web-ui/src/common/util.js b/web-ui/src/common/util.js
index effb3d9c..c70a8444 100644
--- a/web-ui/src/common/util.js
+++ b/web-ui/src/common/util.js
@@ -1,8 +1,27 @@
+import browser from 'helpers/browser';
+
export const hasQueryParameter = (param) => {
const decodedUri = decodeURIComponent(window.location.search.substring(1));
return !(decodedUri.split('&').indexOf(param) < 0);
};
+export const submitForm = (event, url, body = {}) => {
+ event.preventDefault();
+
+ return fetch(url, {
+ credentials: 'same-origin',
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ csrftoken: [browser.getCookie('XSRF-TOKEN')],
+ ...body
+ })
+ });
+};
+
export default {
- hasQueryParameter
+ hasQueryParameter,
+ submitForm
};