Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for non-unique principal name #251

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading