Skip to content

Commit 1ff045f

Browse files
committed
Show post list (admin) from logged user only
1 parent 4ba9695 commit 1ff045f

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

app/Resources/views/admin/blog/index.html.twig

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
<thead>
1010
<tr>
1111
<th scope="col">{{ 'label.title'|trans }}</th>
12-
<th scope="col"><i class="fa fa-user" aria-hidden="true"></i> {{ 'label.author'|trans }}</th>
1312
<th scope="col"><i class="fa fa-calendar" aria-hidden="true"></i> {{ 'label.published_at'|trans }}</th>
14-
<th scope="col"><i class="fa fa-cogs" aria-hidden="true"></i> {{ 'label.actions'|trans }}</th>
13+
<th scope="col" class="col-xs-1"><i class="fa fa-cogs" aria-hidden="true"></i> {{ 'label.actions'|trans }}</th>
1514
</tr>
1615
</thead>
1716
<tbody>
1817
{% for post in posts %}
1918
<tr>
2019
<td>{{ post.title }}</td>
21-
<td>{{ post.authorEmail }}</td>
2220
{# it's not mandatory to set the timezone in localizeddate(). This is done to
2321
avoid errors when the 'intl' PHP extension is not available and the application
2422
is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
@@ -29,11 +27,9 @@
2927
{{ 'action.show'|trans }}
3028
</a>
3129

32-
{% if post.isAuthor(app.user) %}
33-
<a href="{{ path('admin_post_edit', { id: post.id }) }}" class="btn btn-sm btn-primary">
34-
<i class="fa fa-edit" aria-hidden="true"></i> {{ 'action.edit'|trans }}
35-
</a>
36-
{% endif %}
30+
<a href="{{ path('admin_post_edit', { id: post.id }) }}" class="btn btn-sm btn-primary">
31+
<i class="fa fa-edit" aria-hidden="true"></i> {{ 'action.edit'|trans }}
32+
</a>
3733
</div>
3834
</td>
3935
</tr>

src/AppBundle/Controller/Admin/BlogController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class BlogController extends Controller
5555
public function indexAction()
5656
{
5757
$entityManager = $this->getDoctrine()->getManager();
58-
$posts = $entityManager->getRepository(Post::class)->findBy([], ['publishedAt' => 'DESC']);
58+
$posts = $entityManager->getRepository(Post::class)->findBy(['authorEmail' => $this->getUser()->getEmail()], ['publishedAt' => 'DESC']);
5959

6060
return $this->render('admin/blog/index.html.twig', ['posts' => $posts]);
6161
}

0 commit comments

Comments
 (0)