working on db initialization
This commit is contained in:
@@ -2,12 +2,11 @@
|
||||
|
||||
if [ ! -f "/home/svelte/frontend/vite.config.js" ]; then
|
||||
npm create -y vite@6 frontend -- --template svelte
|
||||
cd frontend
|
||||
npm install
|
||||
else
|
||||
echo Svelte-Project recognized, starting…
|
||||
cd frontend
|
||||
fi
|
||||
cd frontend
|
||||
npm install
|
||||
|
||||
npm run dev -- --host 0.0.0.0
|
||||
npm run build
|
||||
|
||||
@@ -10,14 +10,18 @@ import static de.srsoftware.umbrella.user.model.DbUser.ADMIN_PERMISSIONS;
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.tools.PasswordHasher;
|
||||
import de.srsoftware.tools.jdbc.Query;
|
||||
import de.srsoftware.umbrella.core.Token;
|
||||
import de.srsoftware.umbrella.core.UmbrellaException;
|
||||
import de.srsoftware.umbrella.user.BadHasher;
|
||||
import de.srsoftware.umbrella.user.api.LoginServiceDb;
|
||||
import de.srsoftware.umbrella.user.api.UserDb;
|
||||
import de.srsoftware.umbrella.user.model.*;
|
||||
import de.srsoftware.umbrella.user.model.Session;
|
||||
import de.srsoftware.umbrella.user.model.UmbrellaUser;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -127,6 +131,13 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
}
|
||||
|
||||
private void createUserTables() {
|
||||
PasswordHasher<String> hasher;
|
||||
try {
|
||||
hasher = new BadHasher();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
var createTable = """
|
||||
CREATE TABLE IF NOT EXISTS {0} (
|
||||
`{1}` INTEGER,
|
||||
@@ -148,6 +159,13 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
Query.insertInto(TABLE_USERS,LOGIN,PASS,THEME,SETTINGS).values("admin", hasher.hash("admin",null),"default",null).execute(db);
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,"Failed to create first user…");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
createTable = """
|
||||
CREATE TABLE IF NOT EXISTS {0} (
|
||||
{1} INT NOT NULL PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user