diff --git a/src/main/java/eu/m724/Startup.java b/src/main/java/eu/m724/Startup.java index 2e37ea4..e3d3bf2 100644 --- a/src/main/java/eu/m724/Startup.java +++ b/src/main/java/eu/m724/Startup.java @@ -1,20 +1,35 @@ package eu.m724; import eu.m724.orm.Token; +import io.quarkus.runtime.LaunchMode; import io.quarkus.runtime.StartupEvent; import jakarta.enterprise.event.Observes; +import jakarta.inject.Inject; import jakarta.inject.Singleton; import jakarta.transaction.Transactional; +import java.security.SecureRandom; import java.util.Base64; @Singleton public class Startup { + @Inject + LaunchMode launchMode; + @Transactional public void loadUsers(@Observes StartupEvent ignoredEvent) { GlobalAccessLimits.initialize(); Token.deleteAll(); byte[] adminKey = new byte[18]; + System.out.printf("Launch mode: %s\n", launchMode.toString()); + + if (launchMode == LaunchMode.NORMAL) { + System.out.println("Admin token is random"); + new SecureRandom().nextBytes(adminKey); + } else { + // I don't know, but let it be + System.out.println("\n IF THIS IS RUNNING IN PRODUCTION, stop this program now and ask for help.\n"); + } Token token = new Token(); token.accessLimits = GlobalAccessLimits.kilo;