Fix content-type for login (gives error in console of browser)
This commit is contained in:
parent
fd96ba18f1
commit
4a8fdcf887
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user