Skip to content
Snippets Groups Projects

feat(user): [AOU-1772] update user/person firstname and lastname with values...

1 file
+ 22
8
Compare changes
  • Side-by-side
  • Inline
@@ -9,12 +9,12 @@
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
@@ -25,6 +25,9 @@ package ch.unige.aou.model.security;
import java.time.OffsetDateTime;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
@@ -33,9 +36,6 @@ import jakarta.persistence.Transient;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import ch.unige.solidify.auth.model.ApplicationRole;
import ch.unige.solidify.auth.model.AuthUserDto;
import ch.unige.solidify.auth.model.UserInfo;
@@ -116,12 +116,26 @@ public class User extends ResourceNormalized implements UserInfo {
public void setAuthUserDto(AuthUserDto authUserDto) {
// Application Role
if(authUserDto.getApplicationRole() != null) {
if (authUserDto.getApplicationRole() != null) {
this.setApplicationRole(new SolidifyApplicationRole(authUserDto.getApplicationRole()));
}
// User name
if (authUserDto.getLastUpdateWhen().isAfter(this.getLastUpdate().getWhen())) {
// Update name only if properties coming from auth server are more recent than the ones is project
this.setFirstName(authUserDto.getFirstName());
this.setLastName(authUserDto.getLastName());
}
// Person name
if (this.person != null && authUserDto.getLastUpdateWhen().isAfter(this.person.getLastUpdate().getWhen())) {
// Update name only if properties coming from auth server are more recent than the ones is project
this.person.setFirstName(this.getFirstName());
this.person.setLastName(this.getLastName());
}
// Last login
if(authUserDto.getLastLogin() != null) {
if (authUserDto.getLastLogin() != null) {
if (authUserDto.getLastLogin().getLoginIpAddress() != null) {
this.setLastLoginIpAddress(authUserDto.getLastLogin().getLoginIpAddress());
}
@@ -177,6 +191,7 @@ public class User extends ResourceNormalized implements UserInfo {
return this.lastName;
}
@Override
public Person getPerson() {
return this.person;
}
@@ -195,7 +210,6 @@ public class User extends ResourceNormalized implements UserInfo {
return this.externalUid;
}
@Override
public void init() {
// Do nothing
Loading