mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2024-11-04 15:00:14 +01:00
Create InitialSetup.java
This commit is contained in:
parent
e791fee38b
commit
d75e84bdff
@ -0,0 +1,27 @@
|
||||
package stirling.software.SPDF.config.security;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import stirling.software.SPDF.model.Role;
|
||||
@Component
|
||||
public class InitialSetup {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if(!userService.hasUsers()) {
|
||||
String initialUsername = System.getenv("INITIAL_USERNAME");
|
||||
String initialPassword = System.getenv("INITIAL_PASSWORD");
|
||||
if(initialUsername != null && initialPassword != null) {
|
||||
userService.saveUser(initialUsername, initialPassword, Role.ADMIN);
|
||||
} else {
|
||||
userService.saveUser("admin", "password", Role.ADMIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user