Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(function (resolve, reject) {
ajaxCore(opts, wrapError(function (err, res) {
if (err) {
return reject(err);
}
resolve(res);
}));
});
};
var getMembership = toPromise(function (opts, callback) {
var db = this;
if (typeof callback === 'undefined') {
callback = opts;
opts = {};
}
var url = getBaseUrl(db) + '/_membership';
var ajaxOpts = assign({
method: 'GET',
url: url,
headers: getBasicAuthHeaders(db),
}, opts.ajax || {});
ajaxCore(ajaxOpts, wrapError(callback));
});
}
user = assign(user, opts.metadata);
}
if (opts.roles) {
user = assign(user, {roles: opts.roles});
}
var url = getUsersUrl(db) + '/' + encodeURIComponent(user._id);
var ajaxOpts = assign({
method: 'PUT',
url: url,
body: user,
headers: getBasicAuthHeaders(db),
}, opts.ajax || {});
ajaxCore(ajaxOpts, wrapError(callback));
}
var logOut = toPromise(function (opts, callback) {
var db = this;
if (typeof callback === 'undefined') {
callback = opts;
opts = {};
}
var ajaxOpts = assign({
method: 'DELETE',
url: getSessionUrl(db),
headers: getBasicAuthHeaders(db),
}, opts.ajax || {});
ajaxCore(ajaxOpts, wrapError(callback));
});
db.getUser(username, opts, function (error, user) {
if (error) {
return callback(error);
}
var url = getUsersUrl(db) + '/' + encodeURIComponent(user._id) + '?rev=' + user._rev;
var ajaxOpts = assign({
method: 'DELETE',
url: url,
headers: getBasicAuthHeaders(db),
}, opts.ajax || {});
ajaxCore(ajaxOpts, wrapError(callback));
});
});