Skip to content

Commit

Permalink
Fix for JWT assignment 1 log in now works again.
Browse files Browse the repository at this point in the history
Reset button only triggers reset when admin is set to true in the token
  • Loading branch information
nbaars committed May 29, 2018
1 parent 5f4889c commit 589872a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ AttackResult resetVotes(@CookieValue(value = "access_token", required = false) S
Claims claims = (Claims) jwt.getBody();
boolean isAdmin = Boolean.valueOf((String) claims.get("admin"));
if (!isAdmin) {
votes.values().forEach(vote -> vote.reset());
return trackProgress(failed().feedback("jwt-only-admin").build());
} else {
votes.values().forEach(vote -> vote.reset());
Expand Down
15 changes: 8 additions & 7 deletions webgoat-lessons/jwt/src/main/resources/html/JWT.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

<link rel="stylesheet" type="text/css" th:href="@{/lesson_css/jwt.css}"/>
<script th:src="@{/lesson_js/bootstrap.min.js}" language="JavaScript"></script>
<script th:src="@{/lesson_js/jwt-signing.js}" language="JavaScript"></script>
<script th:src="@{/lesson_js/jwt-voting.js}" language="JavaScript"></script>
<div class="attack-container">
<div class="attack-feedback"></div>
<div class="attack-output"></div>
<div class="assignment-success"><i class="fa fa-2 fa-check hidden" aria-hidden="true"></i></div>
<form class="attack-form" accept-charset="UNKNOWN"
method="POST"
Expand All @@ -37,16 +39,16 @@
</button>
<ul class="dropdown-menu dropdown-menu-left">
<li role="presentation"><a role="menuitem" tabindex="-1"
onclick="javascript:login('Guest')"
onclick="javascript:loginVotes('Guest')"
th:text="Guest">current</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1"
onclick="javascript:login('Tom')"
onclick="javascript:loginVotes('Tom')"
th:text="Tom">current</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1"
onclick="javascript:login('Jerry')"
onclick="javascript:loginVotes('Jerry')"
th:text="Jerry">current</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1"
onclick="javascript:login('Sylvester')"
onclick="javascript:loginVotes('Sylvester')"
th:text="Sylvester">current</a></li>
</ul>
<button type="button" class="btn btn-default fa fa-refresh" title="Refresh votes"
Expand All @@ -70,8 +72,7 @@ <h3>Vote for your favorite</h3>
</form>

<br/>
<div class="attack-feedback"></div>
<div class="attack-output"></div>

</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
$(document).ready(function () {
login('Guest');
loginVotes('Guest');
})

function login(user) {
function loginVotes(user) {
$("#name").text(user);
$.ajax({
url: 'JWT/votings/login?user=' + user,
Expand Down

0 comments on commit 589872a

Please sign in to comment.