Skip to content
Snippets Groups Projects
Commit 599c6508 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Merge branch 'master' into models

# Conflicts:
#	server/lib/accounts.coffee
#	server/methods/deleteMessage.coffee
#	server/methods/deleteUser.coffee
#	server/methods/eraseRoom.coffee
#	server/methods/setUserActiveStatus.coffee
#	server/methods/updateMessage.coffee
#	server/publications/adminRooms.coffee
#	server/publications/fullUserData.coffee
#	server/publications/userChannels.coffee
#	server/startup/initialData.coffee
parents f17ea174 a134a870
No related merge requests found
Showing
with 120 additions and 75 deletions
...@@ -85,3 +85,4 @@ todda00:friendly-slugs ...@@ -85,3 +85,4 @@ todda00:friendly-slugs
underscorestring:underscore.string underscorestring:underscore.string
yasaricli:slugify yasaricli:slugify
yasinuslu:blaze-meta yasinuslu:blaze-meta
rocketchat:authorization
...@@ -6,6 +6,7 @@ accounts-meteor-developer@1.0.4 ...@@ -6,6 +6,7 @@ accounts-meteor-developer@1.0.4
accounts-oauth@1.1.5 accounts-oauth@1.1.5
accounts-password@1.1.1 accounts-password@1.1.1
accounts-twitter@1.0.4 accounts-twitter@1.0.4
alanning:roles@1.2.13
aldeed:simple-schema@1.3.3 aldeed:simple-schema@1.3.3
arunoda:streams@0.1.17 arunoda:streams@0.1.17
autoupdate@1.2.1 autoupdate@1.2.1
...@@ -100,6 +101,7 @@ reactive-dict@1.1.0 ...@@ -100,6 +101,7 @@ reactive-dict@1.1.0
reactive-var@1.0.5 reactive-var@1.0.5
reload@1.1.3 reload@1.1.3
retry@1.0.3 retry@1.0.3
rocketchat:authorization@0.0.1
rocketchat:autolinker@0.0.1 rocketchat:autolinker@0.0.1
rocketchat:colors@0.0.1 rocketchat:colors@0.0.1
rocketchat:custom-oauth@1.0.0 rocketchat:custom-oauth@1.0.0
......
...@@ -40,11 +40,15 @@ class @ChatMessages ...@@ -40,11 +40,15 @@ class @ChatMessages
return -1 return -1
edit: (element, index) -> edit: (element, index) ->
return unless RocketChat.settings.get 'Message_AllowEditing' id = element.getAttribute("id")
message = ChatMessage.findOne { _id: id }
hasPermission = RocketChat.authz.hasAtLeastOnePermission('edit-message', message.rid)
editAllowed = RocketChat.settings.get 'Message_AllowEditing'
editOwn = message?.u?._id is Meteor.userId()
return unless hasPermission or (editAllowed and editOwn)
return if element.classList.contains("system") return if element.classList.contains("system")
this.clearEditing() this.clearEditing()
id = element.getAttribute("id")
message = ChatMessage.findOne { _id: id, 'u._id': Meteor.userId() }
this.input.value = message.msg this.input.value = message.msg
this.editing.element = element this.editing.element = element
this.editing.index = index or this.getEditingIndex(element) this.editing.index = index or this.getEditingIndex(element)
......
...@@ -3,9 +3,14 @@ Meteor.methods ...@@ -3,9 +3,14 @@ Meteor.methods
if not Meteor.userId() if not Meteor.userId()
throw new Meteor.Error 203, t('general.User_logged_out') throw new Meteor.Error 203, t('general.User_logged_out')
if not RocketChat.settings.get 'Message_AllowDeleting' hasPermission = RocketChat.authz.hasAtLeastOnePermission('delete-message', message.rid)
deleteAllowed = RocketChat.settings.get 'Message_AllowDeleting'
deleteOwn = message?.u?._id is Meteor.userId()
unless hasPermission or (deleteAllowed and deleteOwn)
throw new Meteor.Error 'message-deleting-not-allowed', t('Message_deleting_not_allowed') throw new Meteor.Error 'message-deleting-not-allowed', t('Message_deleting_not_allowed')
Tracker.nonreactive -> Tracker.nonreactive ->
ChatMessage.remove ChatMessage.remove
_id: message._id _id: message._id
......
...@@ -3,7 +3,13 @@ Meteor.methods ...@@ -3,7 +3,13 @@ Meteor.methods
if not Meteor.userId() if not Meteor.userId()
throw new Meteor.Error 203, t('User_logged_out') throw new Meteor.Error 203, t('User_logged_out')
if not RocketChat.settings.get 'Message_AllowEditing' originalMessage = ChatMessage.findOne message._id
hasPermission = RocketChat.authz.hasAtLeastOnePermission('edit-message', message.rid)
editAllowed = RocketChat.settings.get 'Message_AllowEditing'
editOwn = originalMessage?.u?._id is Meteor.userId()
unless hasPermission or (editAllowed and editOwn)
throw new Meteor.Error 'message-editing-not-allowed', t('Message_editing_not_allowed') throw new Meteor.Error 'message-editing-not-allowed', t('Message_editing_not_allowed')
Tracker.nonreactive -> Tracker.nonreactive ->
......
...@@ -2374,14 +2374,14 @@ a.github-fork { ...@@ -2374,14 +2374,14 @@ a.github-fork {
display: none; display: none;
cursor: pointer; cursor: pointer;
} }
&.own:hover:not(.system) .edit-message { &:hover:not(.system) .edit-message {
display: inline-block; display: inline-block;
} }
.delete-message { .delete-message {
display: none; display: none;
cursor: pointer; cursor: pointer;
} }
&.own:hover:not(.system) .delete-message { &:hover:not(.system) .delete-message {
display: inline-block; display: inline-block;
} }
.user { .user {
......
Template.admin.helpers Template.admin.helpers
isAdmin: ->
return Meteor.user().admin is true
group: -> group: ->
group = FlowRouter.getParam('group') group = FlowRouter.getParam('group')
group ?= Settings.findOne({ type: 'group' })?._id group ?= Settings.findOne({ type: 'group' })?._id
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</h2> </h2>
</head> </head>
<div class="content"> <div class="content">
{{#unless isAdmin}} {{#unless hasPermission 'view-privileged-setting'}}
<p>You are not authorized to view this page.</p> <p>You are not authorized to view this page.</p>
{{else}} {{else}}
{{#with group}} {{#with group}}
......
...@@ -7,24 +7,35 @@ ...@@ -7,24 +7,35 @@
<div class="content"> <div class="content">
<div class="wrapper"> <div class="wrapper">
<ul> <ul>
<li> {{#if hasPermission 'view-statistics'}}
<a href="{{pathFor 'admin-statistics'}}" class="admin-link">{{_ "Statistics"}}</a> <li>
</li> <a href="{{pathFor 'admin-statistics'}}" class="admin-link">{{_ "Statistics"}}</a>
<li> </li>
<a href="{{pathFor 'admin-rooms'}}" class="admin-link">{{_ "Rooms"}}</a> {{/if}}
</li>
<li> {{#if hasPermission 'view-room-administration'}}
<a href="{{pathFor 'admin-users'}}" class="admin-link">{{_ "Users"}}</a> <li>
</li> <a href="{{pathFor 'admin-rooms'}}" class="admin-link">{{_ "Rooms"}}</a>
</li>
{{/if}}
{{#if hasPermission 'view-user-administration'}}
<li>
<a href="{{pathFor 'admin-users'}}" class="admin-link">{{_ "Users"}}</a>
</li>
{{/if}}
<h3 class="add-room"> <h3 class="add-room">
{{_ "Settings"}} {{_ "Settings"}}
</h3> </h3>
{{#each groups}}
<li> {{#if hasPermission 'view-privileged-setting'}}
<a href="{{pathFor 'admin' group=_id}}" class="admin-link">{{_ i18nLabel}}</a> {{#each groups}}
</li> <li>
{{/each}} <a href="{{pathFor 'admin' group=_id}}" class="admin-link">{{_ i18nLabel}}</a>
</li>
{{/each}}
{{/if}}
</ul> </ul>
</div> </div>
</div> </div>
......
Template.adminStatistics.helpers Template.adminStatistics.helpers
isAdmin: ->
return Meteor.user().admin is true
isReady: -> isReady: ->
return Template.instance().ready.get() return Template.instance().ready.get()
statistics: -> statistics: ->
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</h2> </h2>
</head> </head>
<div class="content"> <div class="content">
{{#unless isAdmin}} {{#unless hasPermission 'view-statistics'}}
<p>You are not authorized to view this page.</p> <p>You are not authorized to view this page.</p>
{{else}} {{else}}
{{#if isReady}} {{#if isReady}}
......
Template.adminRoomInfo.helpers Template.adminRoomInfo.helpers
canDeleteRoom: ->
return RocketChat.authz.hasAtLeastOnePermission("delete-#{@t}")
type: -> type: ->
return if @t is 'd' then 'at' else if @t is 'p' then 'lock' else 'hash' return if @t is 'd' then 'at' else if @t is 'p' then 'lock' else 'hash'
name: -> name: ->
......
<template name="adminRoomInfo"> <template name="adminRoomInfo">
<div> {{#unless hasPermission 'view-room-administration'}}
<h3><a href="{{route}}"><i class="icon-{{type}}"></i> {{name}}</a></h3> <p>You are not authorized to view this page.</p>
</div> {{else}}
<div> <div>
<h3>{{_ "Users"}}:</h3> <h3><a href="{{route}}"><i class="icon-{{type}}"></i> {{name}}</a></h3>
{{#each usernames}} </div>
{{.}}<br /> <div>
{{/each}} <h3>{{_ "Users"}}:</h3>
</div> {{#each usernames}}
<nav> {{.}}<br />
<button class='button delete red'><span><i class='icon-trash'></i> {{_ "Delete"}}</span></button> {{/each}}
</nav> </div>
{{#if canDeleteRoom}}
<nav>
<button class='button delete red'><span><i class='icon-trash'></i> {{_ "Delete"}}</span></button>
</nav>
{{/if}}
{{/unless}}
</template> </template>
\ No newline at end of file
Template.adminRooms.helpers Template.adminRooms.helpers
isAdmin: ->
return Meteor.user().admin is true
isReady: -> isReady: ->
return Template.instance().ready?.get() return Template.instance().ready?.get()
rooms: -> rooms: ->
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</h2> </h2>
</head> </head>
<div class="content"> <div class="content">
{{#unless isAdmin}} {{#unless hasPermission 'view-room-administration'}}
<p>You are not authorized to view this page.</p> <p>You are not authorized to view this page.</p>
{{else}} {{else}}
<form class="search-form" role="form"> <form class="search-form" role="form">
......
<template name="adminUserChannels"> <template name="adminUserChannels">
<div class="user-info-channel"> {{#unless hasPermission 'view-full-other-user-info'}}
<h3><a href="{{route}}"><i class="icon-{{type}}"></i> {{name}}</a></h3> <p>You are not authorized to view this page.</p>
</div> {{else}}
<div class="user-info-channel">
<h3><a href="{{route}}"><i class="icon-{{type}}"></i> {{name}}</a></h3>
</div>
{{/unless}}
</template> </template>
\ No newline at end of file
<template name="adminUserEdit"> <template name="adminUserEdit">
<div class="about clearfix"> {{#unless hasPermission 'edit-other-user-info'}}
<form class="edit-form"> <p>You are not authorized to view this page.</p>
<h3>{{name}}</h3> {{else}}
<div class="input-line"> <div class="about clearfix">
<label for="name">{{_ "Name"}}</label> <form class="edit-form">
<input type="text" id="name" autocomplete="off" value="{{name}}"> <h3>{{name}}</h3>
</div> <div class="input-line">
<div class="input-line"> <label for="name">{{_ "Name"}}</label>
<label for="username">{{_ "Username"}}</label> <input type="text" id="name" autocomplete="off" value="{{name}}">
<input type="text" id="username" autocomplete="off" value="{{username}}"> </div>
</div> <div class="input-line">
</form> <label for="username">{{_ "Username"}}</label>
</div> <input type="text" id="username" autocomplete="off" value="{{username}}">
<nav> </div>
<button class='button button-block cancel secondary'><span>{{_ "Cancel"}}</span></button> </form>
<button class='button button-block blue save'><span>{{_ "Save"}}</span></button> </div>
</nav> <nav>
<button class='button button-block cancel secondary'><span>{{_ "Cancel"}}</span></button>
<button class='button button-block blue save'><span>{{_ "Save"}}</span></button>
</nav>
{{/unless}}
</template> </template>
\ No newline at end of file
Template.adminUserInfo.helpers Template.adminUserInfo.helpers
isAdmin: ->
return Meteor.user()?.admin is true
name: -> name: ->
return if @name then @name else TAPi18next.t 'project:Unnamed' return if @name then @name else TAPi18next.t 'project:Unnamed'
email: -> email: ->
...@@ -20,6 +18,9 @@ Template.adminUserInfo.helpers ...@@ -20,6 +18,9 @@ Template.adminUserInfo.helpers
@utcOffset = "+#{@utcOffset}" @utcOffset = "+#{@utcOffset}"
return "UTC #{@utcOffset}" return "UTC #{@utcOffset}"
hasAdminRole: ->
console.log 'hasAdmin: ', RocketChat.authz.hasRole(@_id, 'admin')
return RocketChat.authz.hasRole(@_id, 'admin')
Template.adminUserInfo.events Template.adminUserInfo.events
'click .deactivate': (e) -> 'click .deactivate': (e) ->
......
<template name="adminUserInfo"> <template name="adminUserInfo">
{{#if isAdmin}} {{> userInfo user=.}}
{{> userInfo user=.}} <nav>
<nav> {{#if hasPermission 'edit-other-user-info'}}
<button class='button lightblue edit-user button-block'><span><i class='icon-edit'></i> {{_ "Edit"}}</span></button> <button class='button lightblue edit-user button-block'><span><i class='icon-edit'></i> {{_ "Edit"}}</span></button>
{{#if admin}} {{/if}}
{{#if hasPermission 'assign-admin-role'}}
{{#if hasAdminRole}}
<button class='button lightblue remove-admin button-block'><span><i class='icon-shield'></i> {{_ "Remove_Admin"}}</span></button> <button class='button lightblue remove-admin button-block'><span><i class='icon-shield'></i> {{_ "Remove_Admin"}}</span></button>
{{else}} {{else}}
<button class='button lightblue make-admin button-block'><span><i class='icon-shield'></i> {{_ "Make_Admin"}}</span></button> <button class='button lightblue make-admin button-block'><span><i class='icon-shield'></i> {{_ "Make_Admin"}}</span></button>
{{/if}} {{/if}}
{{/if}}
{{#if hasPermission 'edit-other-user-active-status'}}
{{#if active}} {{#if active}}
<button class='button deactivate button-block'><span><i class='icon-block'></i> {{_ "Deactivate"}}</span></button> <button class='button deactivate button-block'><span><i class='icon-block'></i> {{_ "Deactivate"}}</span></button>
{{else}} {{else}}
<button class='button activate button-block'><span><i class='icon-ok-circled'></i> {{_ "Activate"}}</span></button> <button class='button activate button-block'><span><i class='icon-ok-circled'></i> {{_ "Activate"}}</span></button>
{{/if}} {{/if}}
<button class='button delete red button-block'><span><i class='icon-trash'></i> {{_ "Delete"}}</span></button> {{/if}}
</nav> {{#if hasPermission 'delete-user'}}
{{/if}} <button class='button delete red button-block'><span><i class='icon-trash'></i> {{_ "Delete"}}</span></button>
{{/if}}
</nav>
</template> </template>
\ No newline at end of file
Template.adminUsers.helpers Template.adminUsers.helpers
isAdmin: ->
return Meteor.user().admin is true
isReady: -> isReady: ->
return Template.instance().ready?.get() return Template.instance().ready?.get()
users: -> users: ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment