From dcf13e9ade0ca5216958942306ad7410539563e8 Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Sun, 12 May 2024 20:17:46 +0200 Subject: [PATCH] Update InitialSecuritySetup.java --- .../config/security/InitialSecuritySetup.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java b/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java index f3c534fe..529dd4df 100644 --- a/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java +++ b/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java @@ -33,21 +33,21 @@ public class InitialSecuritySetup { applicationProperties.getSecurity().getInitialLogin().getUsername(); String initialPassword = applicationProperties.getSecurity().getInitialLogin().getPassword(); - try { - // https://github.com/Stirling-Tools/Stirling-PDF/issues/976 - userService.isUsernameValidWithReturn(initialUsername); - } catch (IllegalArgumentException e) { - Path pathToFile = Paths.get("configs/settings.yml"); - try { - if (Files.exists(pathToFile)) { - Files.delete(pathToFile); - } - } catch (IOException ex) { - logger.info(ex.getMessage()); - } - throw e; - } if (initialUsername != null && initialPassword != null) { + try { + // https://github.com/Stirling-Tools/Stirling-PDF/issues/976 + userService.isUsernameValidWithReturn(initialUsername); + } catch (IllegalArgumentException e) { + Path pathToFile = Paths.get("configs/settings.yml"); + try { + if (Files.exists(pathToFile)) { + Files.delete(pathToFile); + } + } catch (IOException ex) { + logger.info(ex.getMessage()); + } + throw e; + } userService.saveUser(initialUsername, initialPassword, Role.ADMIN.getRoleId()); } else { initialUsername = "admin";