You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2017/07/26 08:46:37 UTC

[couchdb-fauxton] branch master updated: (#940) - Use application/x-www-form-urlencoded for _session

This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git


The following commit(s) were added to refs/heads/master by this push:
     new 5d2c857   (#940) - Use application/x-www-form-urlencoded for _session
5d2c857 is described below

commit 5d2c857444f7bc165cbd8162c1d091409a48fa2b
Author: garren smith <ga...@gmail.com>
AuthorDate: Wed Jul 26 10:46:35 2017 +0200

     (#940) - Use application/x-www-form-urlencoded for _session
    
    Use x-www-form-urlencoded instead of application/json so that this will
    work with older versions of CouchDB that don't support application/json
---
 app/addons/auth/api.js | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/app/addons/auth/api.js b/app/addons/auth/api.js
index 4bad314..c509eeb 100644
--- a/app/addons/auth/api.js
+++ b/app/addons/auth/api.js
@@ -27,6 +27,20 @@ export const json = (url, opts = {}) => fetch(
   )
 ).then(resp => resp.json());
 
+export const formEncoded = (url, opts = {}) => fetch(
+  url,
+  defaultsDeep(
+    {
+      credentials: "include",
+      headers: {
+        accept: "application/json",
+        "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
+      }
+    },
+    opts
+  )
+).then(resp => resp.json());
+
 
 export function createAdmin({name, password, node}) {
   return json(`${app.host}/_node/${node}/_config/admins/${name}`, {
@@ -53,17 +67,17 @@ export function getSession() {
 }
 
 export function login(body) {
-  return json(app.host + "/_session", {
+  return formEncoded(app.host + "/_session", {
     method: "POST",
-    body: JSON.stringify(body)
+    body: $.param(body)
   });
 }
 
 export function logout() {
   loggedInSessionPromise = null;
-  return json(app.host + "/_session", {
+  return formEncoded(app.host + "/_session", {
     method: "DELETE",
-    body: JSON.stringify({ username: "_", password: "_" })
+    body: $.param({ username: "_", password: "_" })
   });
 }
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].