|
|
|
@ -20,7 +20,6 @@ import de.srsoftware.umbrella.user.api.UserDb; |
|
|
|
import de.srsoftware.umbrella.user.model.*; |
|
|
|
import de.srsoftware.umbrella.user.model.*; |
|
|
|
import de.srsoftware.umbrella.user.model.Session; |
|
|
|
import de.srsoftware.umbrella.user.model.Session; |
|
|
|
import de.srsoftware.umbrella.user.model.UmbrellaUser; |
|
|
|
import de.srsoftware.umbrella.user.model.UmbrellaUser; |
|
|
|
|
|
|
|
|
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
|
@ -159,8 +158,17 @@ CREATE TABLE IF NOT EXISTS {0} ( |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long count = 0L; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
ResultSet rs = select("COUNT(*)").from(TABLE_USERS).exec(db); |
|
|
|
|
|
|
|
if (rs.next()) count = rs.getLong(1); |
|
|
|
|
|
|
|
rs.close(); |
|
|
|
|
|
|
|
} catch (SQLException ignored) { |
|
|
|
|
|
|
|
// go on with table creation
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
Query.insertInto(TABLE_USERS,LOGIN,PASS,THEME,SETTINGS).values("admin", hasher.hash("admin",null),"default",null).execute(db); |
|
|
|
if (count<1) insertInto(TABLE_USERS,LOGIN,PASS,THEME,SETTINGS).values("admin", hasher.hash("admin",null),"default",null).execute(db); |
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
LOG.log(ERROR,"Failed to create first user…"); |
|
|
|
LOG.log(ERROR,"Failed to create first user…"); |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
|