Allow admins to see last online text (#1540)

* Allow admins to see last online text

* Use viewLastSeenAt permission

* Move permission to UserSerializer, removed from ForumSerializer

* Remove extra comma from ForumSerializer to keep diff clean

* Add permission to new seed migration
This commit is contained in:
David Sevilla Martín 2018-09-22 17:55:53 -04:00 committed by Franz Liedke
parent 5bd13b0c22
commit 46ef76266a
3 changed files with 8 additions and 1 deletions

View File

@ -110,6 +110,12 @@ export default class PermissionGrid extends Component {
})
}, 90);
items.add('viewLastSeenAt', {
icon: 'far fa-clock',
label: app.translator.trans('core.admin.permissions.view_last_seen_at_label'),
permission: 'user.viewLastSeenAt',
});
return items;
}

View File

@ -27,6 +27,7 @@ $rows = [
['permission' => 'discussion.hidePosts', 'group_id' => Group::MODERATOR_ID],
['permission' => 'discussion.rename', 'group_id' => Group::MODERATOR_ID],
['permission' => 'discussion.viewIpsPosts', 'group_id' => Group::MODERATOR_ID],
['permission' => 'user.viewLastSeenAt', 'group_id' => Group::MODERATOR_ID],
];
return [

View File

@ -48,7 +48,7 @@ class UserSerializer extends BasicUserSerializer
'canDelete' => $gate->allows('delete', $user),
];
if ($user->getPreference('discloseOnline')) {
if ($user->getPreference('discloseOnline') || $this->actor->can('viewLastSeenAt', $user)) {
$attributes += [
'lastSeenAt' => $this->formatDate($user->last_seen_at)
];