Skip to content
Snippets Groups Projects
Verified Commit 7290a683 authored by Otto Visser's avatar Otto Visser
Browse files

The user can no longer be found via principal.user but the pages still

tried to (see MR !271)

I hacked my way around it by changing the PermissionService :innocent:


but I hope there is a more elegant solution.

Signed-off-by: default avatarOtto Visser <O.W.Visser@tudelft.nl>
parent 6408b28a
No related branches found
No related tags found
3 merge requests!364Release to master,!360Release 1.2.0,!354Hotfixes2
......@@ -502,7 +502,7 @@ public class PermissionService {
return user.isAdmin() || user.isTeacher();
}
protected User getUser(Object principal) {
public User getUser(Object principal) {
if (!(principal instanceof UserPrincipal)) {
throw new EntityNotFoundException("User was not found");
}
......
......@@ -37,7 +37,7 @@
<h1>Enrol</h1>
</div>
<th:block th:if="${!course.isEnrolled(#authentication.principal.user)}">
<th:block th:if="${!course.isEnrolled(@permissionService.getUser(#authentication.principal))}">
<p>Do you wish to enrol for the course <strong th:text="${course}">Programming 101</strong>?</p>
<form action="#" th:action="@{/course/{id}/enroll(id=${course.id})}" class="form-horizontal" method="post">
......
......@@ -37,7 +37,7 @@
<div class="float-right"
th:if="${@permissionService.canEnqueueSelfForLab(#authentication.principal, lab.id)}">
<th:block
th:unless="${lab.isEnqueued(#authentication.principal.user) || lab.isBeingProcessed(#authentication.principal.user)}">
th:unless="${lab.isEnqueued(@permissionService.getUser(#authentication.principal)) || lab.isBeingProcessed(@permissionService.getUser(#authentication.principal))}">
<a href="#" th:href="@{/lab/{id}/enqueue(id=${lab.id})}"
class="btn btn-sm btn-secondary btn-success">Enqueue</a>
</th:block>
......@@ -60,7 +60,7 @@
</div>
<h3 th:text="'Lab #' + ${lab.id} + ': ' + ${lab.title}"></h3>
<p th:if="${lab.isFeedbackLab() and #authentication.principal.user.isStudent()}">
<p th:if="${lab.isFeedbackLab() and @permissionService.getUser(#authentication.principal).isStudent()}">
Note: you can only enqueue in this lab by submitting an assignment on CPM.
</p>
......@@ -69,19 +69,19 @@
<div class="row">
<div class="col-12">
<div class="card queue-info text-white"
th:if="${lab.isEnqueued(#authentication.principal.user)}">
th:if="${lab.isEnqueued(@permissionService.getUser(#authentication.principal))}">
<h3 class="card-header">You are currently enqueued</h3>
<div class="card-body">
<p th:if="${lab.isSignOffIntervals()}" class="lead">Your time slot is:</p>
<p th:unless="${lab.isSignOffIntervals()}" class="lead">Current position in the queue:</p>
<p id="position" class="lead" th:text="${lab.position(#authentication.principal.user)}"></p>
<p id="position" class="lead" th:text="${lab.position(@permissionService.getUser(#authentication.principal))}"></p>
<p>Once your request has been processed, you can <a th:href="@{/history}"
class="text-white">leave
feedback</a>.</p>
</div>
<div class="card-footer">
<th:block th:if="${lab.isEnqueued(#authentication.principal.user)}">
<th:block th:if="${lab.isEnqueued(@permissionService.getUser(#authentication.principal))}">
<form th:action="@{/lab/{id}/unenqueue(id=${lab.id})}" method="POST">
<button class="btn btn-sm btn-secondary btn-danger">Unenqueue</button>
</form>
......@@ -91,8 +91,8 @@
</div>
<div class="col-12 mt-3"
th:with="request=${lab.getPendingRequest(#authentication.principal.user).get()}"
th:if="${lab.isEnqueued(#authentication.principal.user)}">
th:with="request=${lab.getPendingRequest(@permissionService.getUser(#authentication.principal)).get()}"
th:if="${lab.isEnqueued(@permissionService.getUser(#authentication.principal))}">
<div class="card location-info text-white">
<th:block>
<h3 class="card-header">Update your location and question</h3>
......@@ -235,8 +235,8 @@
th:text="${requesttype.name}"></li>
</ul>
<div th:if="${lab.needsJitsiLink(#authentication.principal.user)}"
th:with="request=${lab.getProcessingRequest(#authentication.principal.user).get()}">
<div th:if="${lab.needsJitsiLink(@permissionService.getUser(#authentication.principal))}"
th:with="request=${lab.getProcessingRequest(@permissionService.getUser(#authentication.principal)).get()}">
<h4 class="card-title">Jitsi Link</h4>
<a th:href="@{${jitsiURL}}" th:target="_blank" class="btn btn-sm btn-secondary">
......@@ -323,15 +323,15 @@
<div class="col-sm-12" style="margin-top:1em;">
<h3>Requests for this lab</h3>
<p>
<th:block th:if="${lab.isEnqueued(#authentication.principal.user)}">
<th:block th:if="${lab.isEnqueued(@permissionService.getUser(#authentication.principal))}">
You are waiting to be processed.
</th:block>
<th:block th:if="${!lab.isEnqueued(#authentication.principal.user)}">
<th:block th:if="${!lab.isEnqueued(@permissionService.getUser(#authentication.principal))}">
You are not enqueued.
</th:block>
<th:block th:if="${lab.isBeingProcessed(#authentication.principal.user)}">
<th:block th:if="${lab.isBeingProcessed(@permissionService.getUser(#authentication.principal))}">
Your request is currently being processed.
</th:block>
</p>
......@@ -392,7 +392,7 @@
</td>
</tr>
<!--todo: make the line below depend on whether you are teacher or student-->
<tr th:if="${lab.countRequestsBy(#authentication.principal.user) == 0}">
<tr th:if="${lab.countRequestsBy(@permissionService.getUser(#authentication.principal)) == 0}">
<td colspan="6">You don't have any requests yet for this lab.</td>
</tr>
</tbody>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment