Add email verification functionality, including backend support, email handling, and user interface integration.

This commit is contained in:
2025-08-23 21:46:10 +02:00
parent da17cf9696
commit 641083732d
26 changed files with 878 additions and 57 deletions
@@ -22,6 +22,7 @@ public class InitializeWebDb {
configuration.addMapper(KeyPairMapper.class);
configuration.addMapper(PrivilegedUserMapper.class);
configuration.addMapper(AppealMapper.class);
configuration.addMapper(com.alttd.altitudeweb.database.web_db.mail.EmailVerificationMapper.class);
}).join()
.runQuery(sqlSession -> {
createSettingsTable(sqlSession);
@@ -29,6 +30,7 @@ public class InitializeWebDb {
createPrivilegedUsersTable(sqlSession);
createPrivilegesTable(sqlSession);
createAppealTable(sqlSession);
createUserEmailsTable(sqlSession);
});
log.debug("Initialized WebDb");
}
@@ -102,6 +104,27 @@ public class InitializeWebDb {
}
}
private static void createUserEmailsTable(@NotNull SqlSession sqlSession) {
String query = """
CREATE TABLE IF NOT EXISTS user_emails (
id UUID NOT NULL DEFAULT (UUID()) PRIMARY KEY,
user_uuid UUID NOT NULL,
email VARCHAR(255) NOT NULL,
verification_code VARCHAR(16) NOT NULL,
verified BOOLEAN NOT NULL DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
verified_at TIMESTAMP NULL,
last_sent_at TIMESTAMP NULL,
FOREIGN KEY (user_uuid) REFERENCES privileged_users(uuid) ON DELETE CASCADE ON UPDATE CASCADE
);
""";
try (Statement statement = sqlSession.getConnection().createStatement()) {
statement.execute(query);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
private static void createAppealTable(@NotNull SqlSession sqlSession) {
String query = """
CREATE TABLE IF NOT EXISTS appeals (