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.Vote;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.web.bind.annotation.*;
@ -75,10 +76,12 @@ public class JWTVotesEndpoint extends AssignmentEndpoint {
Cookie cookie = new Cookie("access_token", token);
response.addCookie(cookie);
response.setStatus(HttpStatus.OK.value());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
} else {
Cookie cookie = new Cookie("access_token", "");
response.addCookie(cookie);
response.setStatus(HttpStatus.UNAUTHORIZED.value());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
}
}

View File

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