Add API to set and transfer ownership

This commit is contained in:
Girish Ramakrishnan
2018-06-28 16:48:04 -07:00
parent ff5bd42bef
commit 9978dff627
6 changed files with 111 additions and 3 deletions

View File

@@ -26,10 +26,13 @@ exports = module.exports = {
setMembership: setMembership,
setTwoFactorAuthenticationSecret: setTwoFactorAuthenticationSecret,
enableTwoFactorAuthentication: enableTwoFactorAuthentication,
disableTwoFactorAuthentication: disableTwoFactorAuthentication
disableTwoFactorAuthentication: disableTwoFactorAuthentication,
transferOwnership: transferOwnership
};
var assert = require('assert'),
var apps = require('./apps.js'),
AppsError = apps.AppsError,
assert = require('assert'),
crypto = require('crypto'),
config = require('./config.js'),
constants = require('./constants.js'),
@@ -641,3 +644,16 @@ function disableTwoFactorAuthentication(userId, callback) {
callback(null);
});
}
function transferOwnership(oldOwnerId, newOwnerId, callback) {
assert.strictEqual(typeof oldOwnerId, 'string');
assert.strictEqual(typeof newOwnerId, 'string');
assert.strictEqual(typeof callback, 'function');
apps.transferOwnership(oldOwnerId, newOwnerId, function (error) {
if (error && error.reason === AppsError.NOT_FOUND) return callback(new UsersError(UsersError.NOT_FOUND, error.message));
if (error) return callback(new UsersError(UsersError.INTERNAL_ERROR, error));
callback(null);
});
}