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