Browse Source

Merge pull request #176 from volodymyr-babak/feature/fix-for-IE-redirect

Fixed IE issue with redirect. 308 return code doesn't work. 303 does.…
pull/180/head
Andrew Shvayka 9 years ago
committed by GitHub
parent
commit
dff1bfe209
  1. 4
      application/src/main/java/org/thingsboard/server/controller/AuthController.java
  2. 2
      application/src/test/java/org/thingsboard/server/controller/AbstractControllerTest.java
  3. 4
      application/src/test/java/org/thingsboard/server/controller/UserControllerTest.java

4
application/src/main/java/org/thingsboard/server/controller/AuthController.java

@ -107,7 +107,7 @@ public class AuthController extends BaseController {
try {
URI location = new URI(createPasswordURI + "?activateToken=" + activateToken);
headers.setLocation(location);
responseStatus = HttpStatus.PERMANENT_REDIRECT;
responseStatus = HttpStatus.SEE_OTHER;
} catch (URISyntaxException e) {
log.error("Unable to create URI with address [{}]", createPasswordURI);
responseStatus = HttpStatus.BAD_REQUEST;
@ -146,7 +146,7 @@ public class AuthController extends BaseController {
try {
URI location = new URI(resetPasswordURI + "?resetToken=" + resetToken);
headers.setLocation(location);
responseStatus = HttpStatus.PERMANENT_REDIRECT;
responseStatus = HttpStatus.SEE_OTHER;
} catch (URISyntaxException e) {
log.error("Unable to create URI with address [{}]", resetPasswordURI);
responseStatus = HttpStatus.BAD_REQUEST;

2
application/src/test/java/org/thingsboard/server/controller/AbstractControllerTest.java

@ -200,7 +200,7 @@ public abstract class AbstractControllerTest {
User savedUser = doPost("/api/user", user, User.class);
logout();
doGet("/api/noauth/activate?activateToken={activateToken}", TestMailService.currentActivateToken)
.andExpect(status().isPermanentRedirect())
.andExpect(status().isSeeOther())
.andExpect(header().string(HttpHeaders.LOCATION, "/login/createPassword?activateToken=" + TestMailService.currentActivateToken));
JsonNode tokenInfo = readResponse(doPost("/api/noauth/activate", "activateToken", TestMailService.currentActivateToken, "password", password).andExpect(status().isOk()), JsonNode.class);
validateAndSetJwtToken(tokenInfo, user.getEmail());

4
application/src/test/java/org/thingsboard/server/controller/UserControllerTest.java

@ -70,7 +70,7 @@ public class UserControllerTest extends AbstractControllerTest {
logout();
doGet("/api/noauth/activate?activateToken={activateToken}", TestMailService.currentActivateToken)
.andExpect(status().isPermanentRedirect())
.andExpect(status().isSeeOther())
.andExpect(header().string(HttpHeaders.LOCATION, "/login/createPassword?activateToken=" + TestMailService.currentActivateToken));
JsonNode tokenInfo = readResponse(doPost("/api/noauth/activate", "activateToken", TestMailService.currentActivateToken, "password", "testPassword").andExpect(status().isOk()), JsonNode.class);
@ -120,7 +120,7 @@ public class UserControllerTest extends AbstractControllerTest {
doPost("/api/noauth/resetPasswordByEmail", "email", email)
.andExpect(status().isOk());
doGet("/api/noauth/resetPassword?resetToken={resetToken}", TestMailService.currentResetPasswordToken)
.andExpect(status().isPermanentRedirect())
.andExpect(status().isSeeOther())
.andExpect(header().string(HttpHeaders.LOCATION, "/login/resetPassword?resetToken=" + TestMailService.currentResetPasswordToken));
JsonNode tokenInfo = readResponse(doPost("/api/noauth/resetPassword", "resetToken", TestMailService.currentResetPasswordToken, "password", "testPassword2").andExpect(status().isOk()), JsonNode.class);

Loading…
Cancel
Save