realm-js/tests/js/admin-user-helper.js

30 lines
706 B
JavaScript
Raw Permalink Normal View History

'use strict';
function node_require(module) {
return require(module);
2017-07-07 10:54:58 +00:00
}
2017-09-18 06:40:46 +00:00
var Realm = node_require('realm');
2017-09-18 06:40:46 +00:00
const adminName = "realm-admin"
const password = '';
exports.createAdminUser = function () {
return new Promise((resolve, reject) => {
2017-09-18 06:40:46 +00:00
Realm.Sync.User.login('http://localhost:9080', adminName, password, (error, user) => {
if (error) {
reject(error);
return;
}
2017-09-18 06:40:46 +00:00
if (!user.isAdmin) {
reject(adminName + " user is not an admin user on this server");
}
2017-09-18 06:40:46 +00:00
resolve({
username: adminName,
password
});
});
});
}