You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by am...@apache.org on 2018/06/27 13:08:05 UTC
[couchdb-fauxton] branch master updated: Change how credentials are
checked when creating a new replication (#1097)
This is an automated email from the ASF dual-hosted git repository.
amaranhao 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 2b9824a Change how credentials are checked when creating a new replication (#1097)
2b9824a is described below
commit 2b9824a0f72355cbb33ed54d6870bbe9328e3053
Author: Antonio Maranhao <30...@users.noreply.github.com>
AuthorDate: Wed Jun 27 09:08:01 2018 -0400
Change how credentials are checked when creating a new replication (#1097)
* When creating a new replication, it checks credentials using 'GET /' instead of 'POST to /_session'
---
app/addons/replication/components/newreplication.js | 18 +++++++++++++-----
app/core/ajax.js | 5 +++--
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/app/addons/replication/components/newreplication.js b/app/addons/replication/components/newreplication.js
index 87b37e2..8a1fd7f 100644
--- a/app/addons/replication/components/newreplication.js
+++ b/app/addons/replication/components/newreplication.js
@@ -10,14 +10,16 @@
// License for the specific language governing permissions and limitations under
// the License.
+import base64 from 'base-64';
import React from 'react';
+import app from '../../../app';
+import {json} from '../../../core/ajax';
import FauxtonAPI from '../../../core/api';
import {ReplicationSource} from './source';
import {ReplicationTarget} from './target';
import {ReplicationOptions} from './options';
import {ReplicationSubmit} from './submit';
import {ReplicationAuth} from './auth-options';
-import AuthAPI from '../../auth/api';
import Constants from '../constants';
import {ConflictModal} from './modals';
import {isEmpty} from 'lodash';
@@ -83,10 +85,7 @@ export default class NewReplicationController extends React.Component {
return FauxtonAPI.Promise.reject(new Error(err));
}
- return AuthAPI.login({
- name: auth.username,
- password: auth.password
- }).then((resp) => {
+ return this.checkCredentials(auth.username, auth.password).then((resp) => {
if (resp.error) {
throw (resp);
}
@@ -101,6 +100,15 @@ export default class NewReplicationController extends React.Component {
});
}
+ checkCredentials(username, password) {
+ return json(app.host + '/', 'GET', {
+ credentials: 'omit',
+ headers: {
+ 'Authorization':'Basic ' + base64.encode(username + ':' + password)
+ }
+ });
+ }
+
checkReplicationDocID () {
const {showConflictModal, replicationDocName, checkReplicationDocID} = this.props;
checkReplicationDocID(replicationDocName).then(existingDoc => {
diff --git a/app/core/ajax.js b/app/core/ajax.js
index e7390fb..7db397c 100644
--- a/app/core/ajax.js
+++ b/app/core/ajax.js
@@ -32,6 +32,8 @@ export const json = (url, method = "GET", opts = {}) => {
return fetch(
url,
defaultsDeep(
+ {},
+ opts,
{
method,
credentials: "include",
@@ -39,8 +41,7 @@ export const json = (url, method = "GET", opts = {}) => {
accept: "application/json",
"Content-Type": "application/json"
}
- },
- opts
+ }
)
).then(resp => {
fetchObserver.next(resp);