# Roles
# Current
1) we do not have system function for bot platfroms
2) Invites to projectm workspace, org
3)
## Points
* When create organization we create new "default" roles
* When create project, you must create role list for this project
## Example for structure
```
{
roleId: 1,
name: "Project Administrator",
availabilityScope: {
typeId: 'system'
}
assignmentScope: {
typeId: 'project',
},
systemFunctionIds: [1,2,3] // all this function must be on project
},
{
roleId: 2,
parentRoleId: 1,
availabilityScope: {
typeId: 'project',
id: 5
}
},
{
roleId:-2,
parentRoleId: 1,
availabilityScope: {
typeId: 'project',
id: 7
}
},
{
roleId: 3,
name: "project member",
availabilityScope: {
typeId: 'project',
id: 5
}
assignmentScope: {
typeId: 'project',
},
systemFunctionIds: [1,2,3] // all this function must be on project
}
// roleId: 3 -- can be assingned in projectId: 5
{
roleId: 4,
name: "bot member extra",
availabilityScope: {
typeId: 'project',
id: 5
}
assignmentScope: {
typeId: 'bot',
},
systemFunctionIds: [1,2,3] // all this function must be on bot
}
// roleId: 4 -- can be assingned in all bots in projectId: 5
{
roleId: 5,
name: "project member", // TODO localization maybe
availabilityScope: {
typeId: 'organization',
id: 5
}
assignmentScope: {
typeId: 'project',
},
systemFunctionIds: [1,2,3] // all this function must be on project
}
// roleId: 5 -- can be assingned in all projects in orhganizationId: 5
{
roleId: 6,
name: "bot member extra for botId:5", // TODO localization maybe
availabilityScope: {
typeId: 'bot',
id: 5
}
assignmentScope: {
typeId: 'bot',
},
systemFunctionIds: [1,2,3] // all this function must be on bot
}
// roleId: 6 -- can be assingned in botId: 5
```
## Flow
We have 4 types of availabilityScope
1) system - roles with such type existing in a system by default and creating manually
2) organization - roles related to the specific organization and creating on the background into the system
3) project - roles related to the specific organization and creating on the background into the system
4) bot - roles related to the specific organization and creating on the background into the system
When we create a new organization we automatically create all roles based on roles with has type system but refer it to current orgnizationId, projectId or botId
### Example
System:
```json=
{
"_id" : ObjectId("5f226f18476ce35f80742be0"),
"systemApplicationId" : 0, -- I don't think that we need it now
"name" : "System users manager basic",
"description" : "System users manager",
"systemFunctionIds" : [
{
"id" : 93,
"availablePermissionTypeIds" : [
1,
2,
3,
4
]
}
],
"roleId" : -113,
"availabilityScope" : {
"typeId" : "system"
},
"assignmentScope" : {
"typeId" : "organization"
}
},
```
When we create new organization we will automatically create role for this organization. This role has a reference to the parent role (which is system) to accumulate functions
```json=
{
"_id" : ObjectId("5f1159bb080da941281c63fa"),
"roleId" : -112,
"availabilityScope" : {
"typeId" : "organization",
"id": 4
},
"parentRoleId" : -133
},
```
### Questions
### Systems' roles
1) Organization
- owner
- viewer
2) Project
-
3) Bot