Merge branch 'cose' into 'dev'

fixed cors on password reset

See merge request sa4-2020/the-sanmarinoes/backend!66
This commit is contained in:
Claudio Maggioni 2020-03-26 01:05:24 +01:00
commit d979050306
2 changed files with 8 additions and 19 deletions

View file

@ -1,7 +1,6 @@
package ch.usi.inf.sa4.sanmarinoes.smarthut.config;
import java.io.IOException;
import java.util.List;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
@ -14,23 +13,13 @@ import org.springframework.stereotype.Component;
@Component
public class CORSFilter implements Filter {
static void setCORSHeaders(HttpServletResponse response) {
public static void setCORSHeaders(HttpServletResponse response) {
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "HEAD, PUT, POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader(
"Access-Control-Allow-Headers",
String.join(
",",
List.of(
"Access-Control-Allow-Headers",
"Origin",
"Accept",
"X-Requested-With",
"Authorization",
"Content-Type",
"Access-Control-Request-Method",
"Access-Control-Request-Headers")));
response.setHeader("Access-Control-Allow-Methods", "*");
response.setHeader("Access-Control-Allow-Headers", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Expose-Headers", "*");
response.setHeader("Access-Control-Max-Age", "6".repeat(99));
}
@Override

View file

@ -160,7 +160,7 @@ public class UserAccountController {
* @throws EmailTokenNotFoundException if given token is not a valid token for password reset
*/
@PutMapping("/reset-password")
public void resetPassword(
public OkResponse resetPassword(
@Valid @RequestBody PasswordResetRequest resetRequest,
final HttpServletResponse response)
throws EmailTokenNotFoundException, IOException {
@ -179,7 +179,7 @@ public class UserAccountController {
// Delete token to prevent further password changes
confirmationTokenRepository.delete(token);
response.sendRedirect(emailConfig.getResetPasswordRedirect());
return new OkResponse();
}
/**