Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
realm.write(() => {
// Create a project
const project = realm.create("Project", {
projectId: uuid(),
owner: user.identity,
name: projectName,
timestamp: new Date()
});
// Fetches the system
const permissionUser = realm.objects("__User").filtered(`id == '${user.identity}'`)[0];
// Create permission
const permission = realm.create(Realm.Permissions.Permission, {
role: permissionUser.role,
canRead: true,
canUpdate: true,
canDelete: true,
})
// Add permission to project
project.permissions.push(permission);
});
// Reset the state
let config = (user) => {
return {
schema: [
{
name: 'Object',
properties: {
value: 'int',
permissions: '__Permission[]'
}
},
Realm.Permissions.Permission,
Realm.Permissions.User,
Realm.Permissions.Role,
],
sync: {user, url: realmUrl, fullSynchronization: false}
};
};
const owner = await Realm.Sync.User.login('http://127.0.0.1:9080', Realm.Sync.Credentials.usernamePassword(global.testAdminUserInfo.username, global.testAdminUserInfo.password));
.then(realm => {
let roles = realm.objects(Realm.Permissions.Role).filtered(`name = '__User:${realm.syncSession.user.identity}'`);
TestCase.assertEqual(roles.length, 1);
realm.write(() => {
const permission = realm.create(Realm.Permissions.Permission,
{ canUpdate: true, canRead: true, canQuery: true, role: roles[0] });
let room = realm.create(PrivateChatRoomSchema.name, { name: `#sales_${Utils.uuid()}` });
room.permissions.push(permission);
});
return waitForUpload(realm);
})
.then(realm => {