Skip to content

Commit 62d50a7

Browse files
committed
Merge pull request #1534 from RocketChat/permissions-renaming
Permissions renaming
2 parents 4777884 + 2a631f7 commit 62d50a7

16 files changed

+26
-23
lines changed

packages/rocketchat-authorization/client/route.coffee

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
FlowRouter.route '/admin/permissions',
2-
name: 'rocket-permissions'
2+
name: 'admin-permissions'
33
action: (params) ->
44
BlazeLayout.render 'main',
55
center: 'pageContainer'
66
pageTitle: t('Permissions')
77
pageTemplate: 'permissions'
88

99
FlowRouter.route '/admin/permissions/:name?/edit',
10-
name: 'rocket-permissions-edit'
10+
name: 'admin-permissions-edit'
1111
action: (params) ->
1212
BlazeLayout.render 'main',
1313
center: 'pageContainer'
1414
pageTitle: t('Role_Editing')
1515
pageTemplate: 'permissionsRole'
1616

1717
FlowRouter.route '/admin/permissions/new',
18-
name: 'rocket-permissions-new'
18+
name: 'admin-permissions-new'
1919
action: (params) ->
2020
BlazeLayout.render 'main',
2121
center: 'pageContainer'
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
RocketChat.authz.subscription = Meteor.subscribe 'permissions'
22

33
RocketChat.AdminBox.addOption
4-
href: 'rocket-permissions'
4+
href: 'admin-permissions'
55
i18nLabel: 'Permissions'
66
permissionGranted: ->
7-
return RocketChat.authz.hasAllPermission('access-rocket-permissions')
7+
return RocketChat.authz.hasAllPermission('access-permissions')

packages/rocketchat-authorization/client/views/permissions.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Template.permissions.helpers
1111
return 'checked' if roles.indexOf(@name) isnt -1
1212

1313
hasPermission: ->
14-
return RocketChat.authz.hasAllPermission 'access-rocket-permissions'
14+
return RocketChat.authz.hasAllPermission 'access-permissions'
1515

1616
Template.permissions.events
1717
'click .role-permission': (e, instance) ->

packages/rocketchat-authorization/client/views/permissions.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
{{#if hasPermission}}
33
<h1>{{_ "Permissions"}}</h1>
44

5-
<a href="{{pathFor "rocket-permissions-new"}}" class="button primary new-role">{{_ "New_role"}}</a>
5+
<a href="{{pathFor "admin-permissions-new"}}" class="button primary new-role">{{_ "New_role"}}</a>
66

77
<table border="1">
88
<tr>
99
<td>&nbsp;</td>
1010
{{#each role}}
11-
<td title="{{description}}"><a href="{{pathFor "rocket-permissions-edit" name=name}}">{{name}}</a></td>
11+
<td title="{{description}}"><a href="{{pathFor "admin-permissions-edit" name=name}}">{{name}}</a></td>
1212
{{/each}}
1313
</tr>
1414
{{#each permission}}

packages/rocketchat-authorization/client/views/permissionsRole.coffee

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
window.rolee = Roles
2-
31
Template.permissionsRole.helpers
42
role: ->
53
return Meteor.roles.findOne({ name: FlowRouter.getParam('name') }) or {}
@@ -15,7 +13,7 @@ Template.permissionsRole.helpers
1513
return @emails[0].address
1614

1715
hasPermission: ->
18-
return RocketChat.authz.hasAllPermission 'access-rocket-permissions'
16+
return RocketChat.authz.hasAllPermission 'access-permissions'
1917

2018
Template.permissionsRole.events
2119

@@ -65,7 +63,7 @@ Template.permissionsRole.events
6563
toastr.success t('Saved')
6664

6765
if not @_id?
68-
FlowRouter.go 'rocket-permissions-edit', { name: roleData.name }
66+
FlowRouter.go 'admin-permissions-edit', { name: roleData.name }
6967

7068

7169
'submit #form-users': (e, instance) ->
@@ -98,7 +96,7 @@ Template.permissionsRole.events
9896

9997
toastr.success t('Role_removed')
10098

101-
FlowRouter.go 'rocket-permissions'
99+
FlowRouter.go 'admin-permissions'
102100

103101
Template.permissionsRole.onCreated ->
104102
# @roles = []

packages/rocketchat-authorization/client/views/permissionsRole.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template name="permissionsRole">
22
{{#if hasPermission}}
3-
<a href="{{pathFor "rocket-permissions"}}">{{_ "Back_to_permissions"}}</a><br><br>
3+
<a href="{{pathFor "admin-permissions"}}">{{_ "Back_to_permissions"}}</a><br><br>
44

55
{{#with role}}
66
<form id="form-role" class="inline">

packages/rocketchat-authorization/server/methods/addPermissionToRole.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Meteor.methods
22
'authorization:addPermissionToRole': (permission, role) ->
3-
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
3+
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
44
throw new Meteor.Error "not-authorized"
55

66
console.log '[methods] authorization:addPermissionToRole -> '.green, 'arguments:', arguments

packages/rocketchat-authorization/server/methods/addUserToRole.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Meteor.methods
22
'authorization:addUserToRole': (roleName, username) ->
3-
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
3+
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
44
throw new Meteor.Error "not-authorized"
55

66
console.log('[methods] authorization:addUserToRole -> '.green, 'arguments:', arguments);

packages/rocketchat-authorization/server/methods/deleteRole.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Meteor.methods
22
'authorization:deleteRole': (_id) ->
3-
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
3+
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
44
throw new Meteor.Error "not-authorized"
55

66
console.log '[methods] authorization:deleteRole -> '.green, 'arguments:', arguments

packages/rocketchat-authorization/server/methods/removeRoleFromPermission.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Meteor.methods
22
'authorization:removeRoleFromPermission': (permission, role) ->
3-
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
3+
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
44
throw new Meteor.Error "not-authorized"
55

66
console.log '[methods] authorization:removeRoleFromPermission -> '.green, 'arguments:', arguments

packages/rocketchat-authorization/server/methods/removeUserFromRole.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Meteor.methods
22
'authorization:removeUserFromRole': (roleName, username) ->
3-
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
3+
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
44
throw new Meteor.Error "not-authorized"
55

66
console.log('[methods] authorization:removeUserFromRole -> '.green, 'arguments:', arguments);

packages/rocketchat-authorization/server/methods/saveRole.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Meteor.methods
22
'authorization:saveRole': (_id, roleData) ->
3-
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
3+
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
44
throw new Meteor.Error "not-authorized"
55

66
console.log '[methods] authorization:saveRole -> '.green, 'arguments:', arguments

packages/rocketchat-authorization/server/publications/roles.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Meteor.publish 'roles', ->
22
unless @userId
33
return @ready()
44

5-
if not RocketChat.authz.hasPermission @userId, 'access-rocket-permissions'
5+
if not RocketChat.authz.hasPermission @userId, 'access-permissions'
66
throw new Meteor.Error "not-authorized"
77

88
return RocketChat.authz.getRoles()

packages/rocketchat-authorization/server/publications/usersInRole.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Meteor.publish 'usersInRole', (roleName, page = 1) ->
22
unless @userId
33
return @ready()
44

5-
if not RocketChat.authz.hasPermission @userId, 'access-rocket-permissions'
5+
if not RocketChat.authz.hasPermission @userId, 'access-permissions'
66
throw new Meteor.Error "not-authorized"
77

88
itemsPerPage = 20

packages/rocketchat-authorization/server/startup.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Meteor.startup ->
8787
{ _id: 'view-d-room',
8888
roles : ['admin', 'site-moderator', 'user']}
8989

90-
{ _id: 'access-rocket-permissions',
90+
{ _id: 'access-permissions',
9191
roles : ['admin']}
9292
]
9393

server/startup/migrations/v24.coffee

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Meteor.startup ->
2+
Migrations.add
3+
version: 24
4+
up: ->
5+
RocketChat.models.Permissions.remove({ _id: 'access-rocket-permissions' })

0 commit comments

Comments
 (0)