Skip to content

Commit

Permalink
Allow for non-unique principal name (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
boavenn authored Oct 22, 2024
1 parent 81f0be3 commit 24e46e7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private Optional<User> getManagerDetails(String managerDN) throws NamingExceptio
var principalNameAttribute = attributes.get(Attribute.PRINCIPAL_NAME.getKey());
var principalName = principalNameAttribute != null ? (String) principalNameAttribute.get() : "";
if (!principalName.isBlank()) {
return this.userRepository.findFirstByPrincipalName(principalName);
return this.userRepository.findFirstByPrincipalNameAndActiveTrue(principalName);
}
}
return Optional.empty();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/info/fingo/urlopia/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class User {
@Column(nullable = false, unique = true)
private String accountName;

@Column(nullable = false, unique = true)
@Column(nullable = false)
private String principalName;

@Column(nullable = false, unique = true)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/info/fingo/urlopia/user/UserRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface UserRepository extends BaseRepository<User>, JpaRepository<User

Optional<User> findFirstByMailAndActiveTrue(String mail);

Optional<User> findFirstByPrincipalName(String principalName);
Optional<User> findFirstByPrincipalNameAndActiveTrue(String principalName);

Optional<User> findFirstByAccountName(String accountName);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE UNIQUE INDEX users_principal_name_index ON users (principal_name);
CREATE UNIQUE INDEX users_principal_name_key ON users (principal_name);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE users DROP CONSTRAINT IF EXISTS users_principal_name_index;
ALTER TABLE users DROP CONSTRAINT IF EXISTS users_principal_name_key;

0 comments on commit 24e46e7

Please sign in to comment.