fix
This commit is contained in:
@@ -107,13 +107,24 @@ public class LibraryService implements ApplicationContextAware {
|
||||
public String authenticateAndGetLibrary(String password) {
|
||||
for (Library library : libraries.values()) {
|
||||
if (passwordEncoder.matches(password, library.getPasswordHash())) {
|
||||
// Mark as explicitly authenticated for this session
|
||||
explicitlyAuthenticated = true;
|
||||
logger.info("User explicitly authenticated for library: {}", library.getId());
|
||||
return library.getId();
|
||||
}
|
||||
}
|
||||
return null; // Authentication failed
|
||||
|
||||
// APP_PASSWORD acts as a master override for recovery access.
|
||||
// Grants access to the "main" library, or the first available one.
|
||||
if (appPassword != null && !appPassword.isBlank() && appPassword.equals(password)) {
|
||||
String libraryId = libraries.containsKey("main")
|
||||
? "main"
|
||||
: libraries.keySet().iterator().next();
|
||||
explicitlyAuthenticated = true;
|
||||
logger.warn("Master APP_PASSWORD used for recovery access to library: {}", libraryId);
|
||||
return libraryId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user