Skip to content

Commit

Permalink
feat: Denote if organization role can be used as the creator
Browse files Browse the repository at this point in the history
We expose a new property as part of the role response, which denotes if the
role can be used as the default organization creator role.
We also align the dummy Role JSON objects with real response objects
  • Loading branch information
chanioxaris committed Nov 17, 2023
1 parent 6ac8d1b commit 01294d2
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 10 deletions.
68 changes: 66 additions & 2 deletions clerk/instance_organization_roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,49 @@ const dummyOrgRoleJson = `{
"name": "custom role",
"key": "org:custom_role",
"description": "my org custom role",
"permissions": [],
"permissions": [
{
"object": "permission",
"id": "perm_2YDDmdVaAyCjmQq6RhrvNsyuUbC",
"name": "Read members",
"key": "org:sys_memberships:read",
"description": "Permission to read the members of an organization.",
"type": "system",
"created_at": 1700051416222,
"updated_at": 1700051416222
},
{
"object": "permission",
"id": "perm_2YDDmcGvIxBiLyPB8mUhLbWhWqG",
"name": "Manage members",
"key": "org:sys_memberships:manage",
"description": "Permission to manage the members of an organization.",
"type": "system",
"created_at": 1700051416224,
"updated_at": 1700051416224
},
{
"object": "permission",
"id": "perm_2YDDmbh2v71OSrvPK5WtUrh8FyX",
"name": "Delete organization",
"key": "org:sys_profile:delete",
"description": "Permission to delete an organization.",
"type": "system",
"created_at": 1700051416221,
"updated_at": 1700051416221
},
{
"object": "permission",
"id": "perm_2YDDmeXfQl3rdJr0FgkIclA1v5I",
"name": "View reports",
"key": "org:report:view",
"description": "Permission to have the ability to view reports.",
"type": "user",
"created_at": 1700051416227,
"updated_at": 1700051416227
}
],
"is_creator_eligible": true,
"created_at": 1610783813,
"updated_at": 1610783813
}`
Expand All @@ -296,7 +338,29 @@ const dummyUpdateOrgRoleJson = `{
"name": "custom org 2",
"key": "org:custom_role_2",
"description": "my org custom role",
"permissions": [],
"permissions": [
{
"object": "permission",
"id": "perm_2YDDmdVaAyCjmQq6RhrvNsyuUbC",
"name": "Read members",
"key": "org:sys_memberships:read",
"description": "Permission to read the members of an organization.",
"type": "system",
"created_at": 1700051416222,
"updated_at": 1700051416222
},
{
"object": "permission",
"id": "perm_2YDDmeXfQl3rdJr0FgkIclA1v5I",
"name": "View reports",
"key": "org:report:view",
"description": "Permission to have the ability to view reports.",
"type": "user",
"created_at": 1700051416227,
"updated_at": 1700051416227
}
],
"is_creator_eligible": false,
"created_at": 1610783813,
"updated_at": 1610783813
}`
17 changes: 9 additions & 8 deletions clerk/roles.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package clerk

type Role struct {
Object string `json:"object"`
ID string `json:"id"`
Name string `json:"name"`
Key string `json:"key"`
Description string `json:"description"`
Permissions []Permission `json:"permissions"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
Object string `json:"object"`
ID string `json:"id"`
Name string `json:"name"`
Key string `json:"key"`
Description string `json:"description"`
Permissions []Permission `json:"permissions"`
IsCreatorEligible bool `json:"is_creator_eligible"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}

type RolesResponse struct {
Expand Down

0 comments on commit 01294d2

Please sign in to comment.