2017-07-05 13:01:31 +00:00
|
|
|
'use strict';
|
2017-11-15 10:59:13 +00:00
|
|
|
const require_method = require;
|
2017-08-11 08:30:57 +00:00
|
|
|
function node_require(module) {
|
2017-11-15 10:59:13 +00:00
|
|
|
return require_method(module);
|
2017-07-07 10:54:58 +00:00
|
|
|
}
|
2017-08-11 08:30:57 +00:00
|
|
|
|
2017-11-10 20:05:35 +00:00
|
|
|
const Realm = node_require('realm');
|
2017-08-11 08:30:57 +00:00
|
|
|
|
2017-09-18 06:40:46 +00:00
|
|
|
const adminName = "realm-admin"
|
|
|
|
const password = '';
|
2017-07-05 13:01:31 +00:00
|
|
|
|
|
|
|
exports.createAdminUser = function () {
|
2018-09-13 06:45:06 +00:00
|
|
|
const credentials = Realm.Sync.Credentials.usernamePassword(adminName, password);
|
|
|
|
return Realm.Sync.User.login('http://localhost:9080', credentials).then((user) => {
|
2017-11-10 20:05:35 +00:00
|
|
|
if (!user.isAdmin) {
|
|
|
|
throw new Error(`${adminName} user is not an admin user on this server`);
|
|
|
|
}
|
2017-09-18 06:40:46 +00:00
|
|
|
|
2017-11-10 20:05:35 +00:00
|
|
|
return {
|
|
|
|
username: adminName,
|
|
|
|
password
|
|
|
|
};
|
2017-07-05 13:01:31 +00:00
|
|
|
});
|
|
|
|
}
|