Fix content-type for login (gives error in console of browser)

This commit is contained in:
Nanne Baars 2018-05-21 19:04:53 +02:00
parent fd96ba18f1
commit 4a8fdcf887
2 changed files with 6 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import org.owasp.webgoat.assignments.AttackResult;
import org.owasp.webgoat.plugin.votes.Views; import org.owasp.webgoat.plugin.votes.Views;
import org.owasp.webgoat.plugin.votes.Vote; import org.owasp.webgoat.plugin.votes.Vote;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.json.MappingJacksonValue; import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -75,10 +76,12 @@ public class JWTVotesEndpoint extends AssignmentEndpoint {
Cookie cookie = new Cookie("access_token", token); Cookie cookie = new Cookie("access_token", token);
response.addCookie(cookie); response.addCookie(cookie);
response.setStatus(HttpStatus.OK.value()); response.setStatus(HttpStatus.OK.value());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
} else { } else {
Cookie cookie = new Cookie("access_token", ""); Cookie cookie = new Cookie("access_token", "");
response.addCookie(cookie); response.addCookie(cookie);
response.setStatus(HttpStatus.UNAUTHORIZED.value()); response.setStatus(HttpStatus.UNAUTHORIZED.value());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
} }
} }

View File

@ -5,8 +5,9 @@ $(document).ready(function () {
function login(user) { function login(user) {
$("#name").text(user); $("#name").text(user);
$.ajax({ $.ajax({
url: 'JWT/votings/login?user=' + user url: 'JWT/votings/login?user=' + user,
}).then(function () { contentType: "application/json"
}).always(function () {
getVotings(); getVotings();
}) })
} }