mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-23 16:05:09 +00:00
Compare commits
4 Commits
0d36e74276
...
77e9823a1a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
77e9823a1a | ||
![]() |
5393ae24cb | ||
![]() |
142dba185c | ||
![]() |
069b71be2c |
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -86,4 +86,9 @@
|
|||||||
"spring.initializr.defaultLanguage": "Java",
|
"spring.initializr.defaultLanguage": "Java",
|
||||||
"spring.initializr.defaultGroupId": "stirling.software.SPDF",
|
"spring.initializr.defaultGroupId": "stirling.software.SPDF",
|
||||||
"spring.initializr.defaultArtifactId": "SPDF",
|
"spring.initializr.defaultArtifactId": "SPDF",
|
||||||
|
"java.project.sourcePaths": [
|
||||||
|
"stirling-pdf/src/main/java",
|
||||||
|
"common/src/main/java",
|
||||||
|
"proprietary/src/main/java"
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package stirling.software.proprietary.security;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -53,11 +54,16 @@ public class InitialSecuritySetup {
|
|||||||
|
|
||||||
private void assignUsersToDefaultTeamIfMissing() {
|
private void assignUsersToDefaultTeamIfMissing() {
|
||||||
Team defaultTeam = teamService.getOrCreateDefaultTeam();
|
Team defaultTeam = teamService.getOrCreateDefaultTeam();
|
||||||
|
Team internalTeam = teamService.getOrCreateInternalTeam();
|
||||||
List<User> usersWithoutTeam = userService.getUsersWithoutTeam();
|
List<User> usersWithoutTeam = userService.getUsersWithoutTeam();
|
||||||
|
|
||||||
for (User user : usersWithoutTeam) {
|
for (User user : usersWithoutTeam) {
|
||||||
|
if (user.getUsername().equalsIgnoreCase(Role.INTERNAL_API_USER.getRoleId())) {
|
||||||
|
user.setTeam(internalTeam);
|
||||||
|
} else {
|
||||||
user.setTeam(defaultTeam);
|
user.setTeam(defaultTeam);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
userService.saveAll(usersWithoutTeam); // batch save
|
userService.saveAll(usersWithoutTeam); // batch save
|
||||||
log.info(
|
log.info(
|
||||||
@ -108,6 +114,20 @@ public class InitialSecuritySetup {
|
|||||||
false);
|
false);
|
||||||
userService.addApiKeyToUser(Role.INTERNAL_API_USER.getRoleId());
|
userService.addApiKeyToUser(Role.INTERNAL_API_USER.getRoleId());
|
||||||
log.info("Internal API user created: {}", Role.INTERNAL_API_USER.getRoleId());
|
log.info("Internal API user created: {}", Role.INTERNAL_API_USER.getRoleId());
|
||||||
|
} else {
|
||||||
|
Optional<User> internalApiUserOpt =
|
||||||
|
userService.findByUsernameIgnoreCase(Role.INTERNAL_API_USER.getRoleId());
|
||||||
|
if (internalApiUserOpt.isPresent()) {
|
||||||
|
User internalApiUser = internalApiUserOpt.get();
|
||||||
|
// move to team internal API user
|
||||||
|
if (!internalApiUser.getTeam().getName().equals(TeamService.INTERNAL_TEAM_NAME)) {
|
||||||
|
log.info(
|
||||||
|
"Moving internal API user to team: {}", TeamService.INTERNAL_TEAM_NAME);
|
||||||
|
Team internalTeam = teamService.getOrCreateInternalTeam();
|
||||||
|
|
||||||
|
userService.changeUserTeam(internalApiUser, internalTeam);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
userService.syncCustomApiUser(applicationProperties.getSecurity().getCustomGlobalAPIKey());
|
userService.syncCustomApiUser(applicationProperties.getSecurity().getCustomGlobalAPIKey());
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class User implements Serializable {
|
|||||||
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "user")
|
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "user")
|
||||||
private Set<Authority> authorities = new HashSet<>();
|
private Set<Authority> authorities = new HashSet<>();
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "team_id")
|
@JoinColumn(name = "team_id")
|
||||||
private Team team;
|
private Team team;
|
||||||
|
|
||||||
|
@ -371,6 +371,16 @@ public class UserService implements UserServiceInterface {
|
|||||||
databaseService.exportDatabase();
|
databaseService.exportDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void changeUserTeam(User user, Team team)
|
||||||
|
throws SQLException, UnsupportedProviderException {
|
||||||
|
if (team == null) {
|
||||||
|
team = getDefaultTeam();
|
||||||
|
}
|
||||||
|
user.setTeam(team);
|
||||||
|
userRepository.save(user);
|
||||||
|
databaseService.exportDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPasswordCorrect(User user, String currentPassword) {
|
public boolean isPasswordCorrect(User user, String currentPassword) {
|
||||||
return passwordEncoder.matches(currentPassword, user.getPassword());
|
return passwordEncoder.matches(currentPassword, user.getPassword());
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ document.addEventListener('DOMContentLoaded', async function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const response = await fetch('files/popularity.txt');
|
const response = await fetch('/files/popularity.txt');
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user