Skip to content

Commit

Permalink
Backend patch number 1 (#60)
Browse files Browse the repository at this point in the history
A Backend patch has been made to sort the following issues:
- Remove the repeatNewPassword field from the JSON Request when trying to change a user's password.
- Change endpoint /login/ for /api/v1/login
- Remove the ApplicationExceptionMapper because it was catching a Java WS NotFoundException and returning a 500 Server Error instead of a proper 404 Not Found error, so a resource that did not exist would return a 500 error.
  • Loading branch information
gibarsin authored Jan 26, 2017
1 parent dca63d2 commit ef7923c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected void configure(final HttpSecurity http) throws Exception {
.and()
.authorizeRequests()
.antMatchers(HttpMethod.POST,"/api/v1/login").permitAll()
.antMatchers("/**").authenticated()
.anyRequest().authenticated()
.and()
.addFilterBefore(new StatelessLoginFilter("/api/v1/login", tokenAuthenticationService, userDetailsService, authenticationManager()), UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(new StatelessAuthenticationFilter(tokenAuthenticationService), UsernamePasswordAuthenticationFilter.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ar.edu.itba.paw.webapp.controllers;

import ar.edu.itba.paw.interfaces.UserService;
import ar.edu.itba.paw.webapp.forms.PasswordForm;
import ar.edu.itba.paw.webapp.forms.PasswordDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -31,10 +31,10 @@ public class UserController {
@Path("/{dni}/password/change")
@Consumes(MediaType.APPLICATION_JSON)
public Response usersPasswordChange(@PathParam("dni") final int dni,
@Valid PasswordForm passwordForm) {
passwordForm.setDni(dni);
@Valid PasswordDTO passwordDTO) {
passwordDTO.setDni(dni);

if(!us.changePassword(dni, passwordForm.getCurrentPassword(), passwordForm.getNewPassword())) {
if(!us.changePassword(dni, passwordDTO.getCurrentPassword(), passwordDTO.getNewPassword())) {
return status(Status.BAD_REQUEST).build();
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

import javax.validation.constraints.Size;

public class PasswordForm {
// @Digits(integer=8, fraction=0)
// @NotNull
public class PasswordDTO {
private int dni;

@NotBlank
Expand All @@ -16,10 +14,6 @@ public class PasswordForm {
@Size(min=8, max=32)
private String newPassword;

@NotBlank
@Size(min=8, max=32)
private String repeatNewPassword;

public int getDni() {
return dni;
}
Expand All @@ -43,12 +37,4 @@ public String getNewPassword() {
public void setNewPassword(final String newPassword) {
this.newPassword = newPassword;
}

public String getRepeatNewPassword() {
return repeatNewPassword;
}

public void setRepeatNewPassword(final String repeatNewPassword) {
this.repeatNewPassword = repeatNewPassword;
}
}

This file was deleted.

0 comments on commit ef7923c

Please sign in to comment.