aboutsummaryrefslogtreecommitdiff
path: root/juick-spring-www/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'juick-spring-www/src/main')
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java4
-rw-r--r--juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/blog_messages.html12
2 files changed, 9 insertions, 7 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
index 4576e9d3..ffc64221 100644
--- a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
+++ b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
@@ -96,6 +96,9 @@ public class IndexController {
model.addAttribute("msgs",
msgs.stream().map(msg -> {
msg.ReadOnly |= blUIDs.contains(msg.getUser().getUid());
+ if (msg.ReadOnly) {
+ msg.ReadOnly = visitor.getUid() != msg.getUser().getUid();
+ }
return msg;
}).collect(Collectors.toList())
);
@@ -109,7 +112,6 @@ public class IndexController {
}
model.addAttribute("nextpage", nextpage);
}
- //model.addAttribute("isModerator", userService.getModerators().contains(visitor.getUid()));
return "views/index";
}
diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/blog_messages.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/blog_messages.html
index b444acc2..2bf0e627 100644
--- a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/blog_messages.html
+++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/blog_messages.html
@@ -25,15 +25,15 @@
<p th:utext="${msg.getText()}">Lorem ipsum</p>
<div class="irbr" th:if="${msg.getAttachmentType() != null}"></div>
<nav class="l">
- <th:block th:switch="${visitor.getUid()}">
- <a th:case="0" class="a-login" th:href="|/${msg.getMid()}/|">Рекомендовать</a>
- <a th:case="*" class="a-like" th:href="|/post?body=!+%23${msg.getMid()}/|">Рекомендовать</a>
+ <th:block th:switch="${#authorization.expression('isAuthenticated()')}">
+ <a th:case="false" class="a-login" th:href="|/${msg.getMid()}/|">Рекомендовать</a>
+ <a th:case="true" class="a-like" th:href="|/post?body=!+%23${msg.getMid()}/|">Рекомендовать</a>
</th:block>
- <a th:if="${visitor.getUid() == 0 && !msg.ReadOnly}" class="a-login" th:href="|/${msg.getMid()}/|">Комментировать</a>
- <a th:if="${visitor.getUid() > 0 && (!msg.ReadOnly || visitor.getUid() == msg.getUser().getUid())}"
+ <a th:if="${#authorization.expression('isAuthenticated()') == false && !msg.ReadOnly}" class="a-login" th:href="|/${msg.getMid()}/|">Комментировать</a>
+ <a th:if="${#authorization.expression('isAuthenticated()') == true && !msg.ReadOnly}"
class="a-comment" th:href="|/${msg.getMid()}/|">Комментировать</a>
- <th:block th:if="${visitor.getUid() == 3694}">
+ <th:block th:if="${#authorization.expression('hasRole(''ROLE_ADMIN'')')}">
<a href="#" class="a-popular-plus">+</a>
<a href="#" class="a-popular-minus">-</a>
<a href="#" class="a-popular-delete">x</a>