diff options
| author | Tulio Casagrande <tuliocasagrande@gmail.com> | 2017-04-04 13:14:34 -0300 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-04 13:14:34 -0300 | 
| commit | f70c2827d41d1d805d6446670b861b7abf0761b1 (patch) | |
| tree | df266fda0c593a27c568215716d48d9994fbd344 /web-ui/src/common/util.js | |
| parent | af454c71da106644eee644c4286bbae4788b8e14 (diff) | |
| parent | d7914b9b5640c3d85c6230a032180b2e64520bca (diff) | |
Merge pull request #1042 from pixelated/login-recovery-code
[#935] Sends user recovery code and password to account recovery endpoint
Diffstat (limited to 'web-ui/src/common/util.js')
| -rw-r--r-- | web-ui/src/common/util.js | 21 | 
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  }; | 
