Repository: urlaubsverwaltung/urlaubsverwaltung
Pull request #4478 (2024-01-12 12:57:23)

Fix wrong first- and lastname on newly created users
<!--

Thanks for contributing to the Urlaubsverwaltung.
Please review the following notes before submitting you pull request.

Please look for other issues or pull requests which already work on this topic. Is somebody already on it? Do you need to synchronize?

# Security Vulnerabilities

🛑 STOP! 🛑 If your contribution fixes a security vulnerability, please do not submit it.
Instead, please open a report of a security vulnerability via
[Report a security vulnerability](https://github.com/urlaubsverwaltung/urlaubsverwaltung/security/advisories/new)


# Describing Your Changes

If, having reviewed the notes above, you're ready to submit your pull request, please
provide a brief description of the proposed changes.

If they:
 🐞 fix a bug, please describe the broken behaviour and how the changes fix it.
    Please label with 'type: bug' and 'status: new'
    
 🎁 make an enhancement, please describe the new functionality and why you believe it's useful.
    Please label with 'type: enhancement' and 'status: new'
 
If your pull request relates to any existing issues,
please reference them by using the issue number prefixed with #.

-->



Patch:
diff --git a/src/main/java/org/synyx/urlaubsverwaltung/security/oidc/PersonOnSuccessfullyOidcLoginEventHandler.java b/src/main/java/org/synyx/urlaubsverwaltung/security/oidc/PersonOnSuccessfullyOidcLoginEventHandler.java
index 9c88dedf1..d708710c0 100644
--- a/src/main/java/org/synyx/urlaubsverwaltung/security/oidc/PersonOnSuccessfullyOidcLoginEventHandler.java
+++ b/src/main/java/org/synyx/urlaubsverwaltung/security/oidc/PersonOnSuccessfullyOidcLoginEventHandler.java
@@ -66,7 +66,7 @@ class PersonOnSuccessfullyOidcLoginEventHandler {
             personService.update(existentPerson);
 
         } else {
-            final Person createdPerson = personService.create(userUniqueID, lastName, firstName, emailAddress);
+            final Person createdPerson = personService.create(userUniqueID, firstName, lastName, emailAddress);
             personService.appointAsOfficeUserIfNoOfficeUserPresent(createdPerson);
         }
     }


Test patch:
diff --git a/src/test/java/org/synyx/urlaubsverwaltung/security/oidc/PersonOnSuccessfullyOidcLoginEventHandlerTest.java b/src/test/java/org/synyx/urlaubsverwaltung/security/oidc/PersonOnSuccessfullyOidcLoginEventHandlerTest.java
index fa29f2fb7..a2d930cf0 100644
--- a/src/test/java/org/synyx/urlaubsverwaltung/security/oidc/PersonOnSuccessfullyOidcLoginEventHandlerTest.java
+++ b/src/test/java/org/synyx/urlaubsverwaltung/security/oidc/PersonOnSuccessfullyOidcLoginEventHandlerTest.java
@@ -72,14 +72,14 @@ class PersonOnSuccessfullyOidcLoginEventHandlerTest {
 
             when(personService.getPersonByUsername(uniqueID)).thenReturn(Optional.empty());
             when(personService.getPersonByMailAddress(email)).thenReturn(Optional.empty());
-            when(personService.create(uniqueID, familyName, givenName, email)).thenReturn(new Person(uniqueID, familyName, givenName, email));
+            when(personService.create(uniqueID, givenName, familyName, email)).thenReturn(new Person(uniqueID, familyName, givenName, email));
 
             sut.handle(event);
 
             verify(personService).getPersonByUsername(uniqueID);
             verify(personService).getPersonByMailAddress(email);
 
-            verify(personService).create(uniqueID, familyName, givenName, email);
+            verify(personService).create(uniqueID, givenName, familyName, email);
 
             final ArgumentCaptor<Person> personArgumentCaptor = ArgumentCaptor.forClass(Person.class);
             verify(personService).appointAsOfficeUserIfNoOfficeUserPresent(personArgumentCaptor.capture());