Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions renaming #1534

Merged
merged 3 commits into from
Dec 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/rocketchat-authorization/client/route.coffee
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FlowRouter.route '/admin/permissions',
name: 'rocket-permissions'
name: 'admin-permissions'
action: (params) ->
BlazeLayout.render 'main',
center: 'pageContainer'
pageTitle: t('Permissions')
pageTemplate: 'permissions'

FlowRouter.route '/admin/permissions/:name?/edit',
name: 'rocket-permissions-edit'
name: 'admin-permissions-edit'
action: (params) ->
BlazeLayout.render 'main',
center: 'pageContainer'
pageTitle: t('Role_Editing')
pageTemplate: 'permissionsRole'

FlowRouter.route '/admin/permissions/new',
name: 'rocket-permissions-new'
name: 'admin-permissions-new'
action: (params) ->
BlazeLayout.render 'main',
center: 'pageContainer'
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-authorization/client/startup.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RocketChat.authz.subscription = Meteor.subscribe 'permissions'

RocketChat.AdminBox.addOption
href: 'rocket-permissions'
href: 'admin-permissions'
i18nLabel: 'Permissions'
permissionGranted: ->
return RocketChat.authz.hasAllPermission('access-rocket-permissions')
return RocketChat.authz.hasAllPermission('access-permissions')
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Template.permissions.helpers
return 'checked' if roles.indexOf(@name) isnt -1

hasPermission: ->
return RocketChat.authz.hasAllPermission 'access-rocket-permissions'
return RocketChat.authz.hasAllPermission 'access-permissions'

Template.permissions.events
'click .role-permission': (e, instance) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{{#if hasPermission}}
<h1>{{_ "Permissions"}}</h1>

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

<table border="1">
<tr>
<td>&nbsp;</td>
{{#each role}}
<td title="{{description}}"><a href="{{pathFor "rocket-permissions-edit" name=name}}">{{name}}</a></td>
<td title="{{description}}"><a href="{{pathFor "admin-permissions-edit" name=name}}">{{name}}</a></td>
{{/each}}
</tr>
{{#each permission}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
window.rolee = Roles

Template.permissionsRole.helpers
role: ->
return Meteor.roles.findOne({ name: FlowRouter.getParam('name') }) or {}
Expand All @@ -15,7 +13,7 @@ Template.permissionsRole.helpers
return @emails[0].address

hasPermission: ->
return RocketChat.authz.hasAllPermission 'access-rocket-permissions'
return RocketChat.authz.hasAllPermission 'access-permissions'

Template.permissionsRole.events

Expand Down Expand Up @@ -65,7 +63,7 @@ Template.permissionsRole.events
toastr.success t('Saved')

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


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

toastr.success t('Role_removed')

FlowRouter.go 'rocket-permissions'
FlowRouter.go 'admin-permissions'

Template.permissionsRole.onCreated ->
# @roles = []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template name="permissionsRole">
{{#if hasPermission}}
<a href="{{pathFor "rocket-permissions"}}">{{_ "Back_to_permissions"}}</a><br><br>
<a href="{{pathFor "admin-permissions"}}">{{_ "Back_to_permissions"}}</a><br><br>

{{#with role}}
<form id="form-role" class="inline">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Meteor.methods
'authorization:addPermissionToRole': (permission, role) ->
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"

console.log '[methods] authorization:addPermissionToRole -> '.green, 'arguments:', arguments
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Meteor.methods
'authorization:addUserToRole': (roleName, username) ->
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"

console.log('[methods] authorization:addUserToRole -> '.green, 'arguments:', arguments);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Meteor.methods
'authorization:deleteRole': (_id) ->
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"

console.log '[methods] authorization:deleteRole -> '.green, 'arguments:', arguments
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Meteor.methods
'authorization:removeRoleFromPermission': (permission, role) ->
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"

console.log '[methods] authorization:removeRoleFromPermission -> '.green, 'arguments:', arguments
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Meteor.methods
'authorization:removeUserFromRole': (roleName, username) ->
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"

console.log('[methods] authorization:removeUserFromRole -> '.green, 'arguments:', arguments);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Meteor.methods
'authorization:saveRole': (_id, roleData) ->
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-rocket-permissions'
if not Meteor.userId() or not RocketChat.authz.hasPermission Meteor.userId(), 'access-permissions'
throw new Meteor.Error "not-authorized"

console.log '[methods] authorization:saveRole -> '.green, 'arguments:', arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Meteor.publish 'roles', ->
unless @userId
return @ready()

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

return RocketChat.authz.getRoles()
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Meteor.publish 'usersInRole', (roleName, page = 1) ->
unless @userId
return @ready()

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

itemsPerPage = 20
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-authorization/server/startup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Meteor.startup ->
{ _id: 'view-d-room',
roles : ['admin', 'site-moderator', 'user']}

{ _id: 'access-rocket-permissions',
{ _id: 'access-permissions',
roles : ['admin']}
]

Expand Down
5 changes: 5 additions & 0 deletions server/startup/migrations/v24.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Meteor.startup ->
Migrations.add
version: 24
up: ->
RocketChat.models.Permissions.remove({ _id: 'access-rocket-permissions' })