Skip to content

Commit

Permalink
BF7 - Authentification (set user info fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisClone committed Dec 13, 2019
1 parent 9daf2de commit 318f077
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/main/java/fr/kungfunantes/backend/model/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ public void setId(Long id) {
this.id = id;
}

public String getFirstname() {
public String getFirstName() {
return firstname;
}

public void setFirstname(String firstname) {
public void setFirstName(String firstname) {
this.firstname = firstname;
}

public String getLastname() {
public String getLastName() {
return lastname;
}

public void setLastname(String lastname) {
public void setLastName(String lastname) {
this.lastname = lastname;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public ResponseEntity<Profile> updateProfile(@RequestBody Profile profile, @Path

// do the update
Profile updateProfile = optionalProfile.get();
updateProfile.setFirstname(profile.getFirstname());
updateProfile.setLastname(profile.getLastname());
updateProfile.setFirstName(profile.getFirstName());
updateProfile.setLastName(profile.getLastName());
profileRepository.save(updateProfile);

// return the updated value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public ResponseEntity<?> registerUser(@Valid @RequestBody SignUpRequest signUpRe
}

// Creating user's account
Profile user = new Profile(signUpRequest.getFirstname(), signUpRequest.getLastname(), signUpRequest.getUsername(),
Profile user = new Profile(signUpRequest.getFirstName(), signUpRequest.getLastName(), signUpRequest.getUsername(),
signUpRequest.getEmail(), signUpRequest.getPassword());

user.setPassword(passwordEncoder.encode(user.getPassword()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ public class SignUpRequest {
@Size(min = 6, max = 20)
private String password;

public String getFirstname() {
public String getFirstName() {
return firstname;
}

public void setFirstname(String name) {
public void setFirstName(String name) {
this.firstname = name;
}

public String getLastname() {
public String getLastName() {
return lastname;
}

public void setLastname(String name) {
public void setLastName(String name) {
this.lastname = name;
}

Expand All @@ -63,4 +63,4 @@ public String getPassword() {
public void setPassword(String password) {
this.password = password;
}
}
}
23 changes: 14 additions & 9 deletions src/main/java/fr/kungfunantes/backend/security/UserPrincipal.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ public class UserPrincipal implements UserDetails {
private static final long serialVersionUID = 1L;

private Long id;

private String name;

private String firstName;
private String lastName;
private String username;

@JsonIgnore
Expand All @@ -31,9 +30,10 @@ public class UserPrincipal implements UserDetails {

private Collection<? extends GrantedAuthority> authorities;

public UserPrincipal(Long id, String name, String username, String email, String password, Collection<? extends GrantedAuthority> authorities) {
public UserPrincipal(Long id, String firstName, String lastName, String username, String email, String password, Collection<? extends GrantedAuthority> authorities) {
this.id = id;
this.name = name;
this.firstName = firstName;
this.lastName = lastName;
this.username = username;
this.email = email;
this.password = password;
Expand All @@ -47,7 +47,8 @@ public static UserPrincipal create(Profile user) {

return new UserPrincipal(
user.getId(),
user.getLastname(),
user.getFirstName(),
user.getLastName(),
user.getUsername(),
user.getEmail(),
user.getPassword(),
Expand All @@ -59,8 +60,12 @@ public Long getId() {
return id;
}

public String getName() {
return name;
public String getFirstName() {
return firstName;
}

public String getLastname() {
return lastName;
}

public String getEmail() {
Expand Down Expand Up @@ -115,4 +120,4 @@ public int hashCode() {

return Objects.hash(id);
}
}
}

0 comments on commit 318f077

Please sign in to comment.