Gitea-Repo fix
Dieser Commit ist enthalten in:
committet von
Server Deploy
Ursprung
c21be47428
Commit
623bbdf5dd
@ -170,6 +170,63 @@ function createTables() {
|
||||
logger.info('Migration: repositories_base_path Spalte zu users hinzugefuegt');
|
||||
}
|
||||
|
||||
// Migration: Add custom_initials column to users
|
||||
const hasCustomInitials = userColumns.some(col => col.name === 'custom_initials');
|
||||
if (!hasCustomInitials) {
|
||||
db.exec("ALTER TABLE users ADD COLUMN custom_initials TEXT");
|
||||
logger.info('Migration: custom_initials Spalte zu users hinzugefuegt');
|
||||
}
|
||||
|
||||
// Migration: Add initials column and prepare email
|
||||
const hasInitials = userColumns.some(col => col.name === 'initials');
|
||||
if (!hasInitials && userColumns.some(col => col.name === 'username')) {
|
||||
logger.info('Migration: Füge initials Spalte hinzu und bereite E-Mail vor');
|
||||
|
||||
// Zuerst Daten vorbereiten
|
||||
const users = db.prepare('SELECT id, username, email, custom_initials FROM users').all();
|
||||
for (const user of users) {
|
||||
// Stelle sicher dass jeder Benutzer eine E-Mail hat
|
||||
if (!user.email || user.email === '') {
|
||||
if (user.username === 'admin') {
|
||||
// Admin bekommt eine spezielle E-Mail
|
||||
db.prepare('UPDATE users SET email = ? WHERE id = ?').run('admin@taskmate.local', user.id);
|
||||
} else if (user.username.includes('@')) {
|
||||
// Username enthält bereits E-Mail (wie bei bestehenden Benutzern)
|
||||
db.prepare('UPDATE users SET email = ? WHERE id = ?').run(user.username, user.id);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialen setzen (aus custom_initials oder generieren)
|
||||
if (!user.custom_initials || user.custom_initials === '') {
|
||||
let initials = 'XX';
|
||||
if (user.username === 'admin') {
|
||||
initials = 'AD';
|
||||
} else if (user.email || user.username.includes('@')) {
|
||||
// Generiere Initialen aus E-Mail
|
||||
const emailPart = (user.email || user.username).split('@')[0];
|
||||
if (emailPart.includes('_')) {
|
||||
const parts = emailPart.split('_');
|
||||
initials = (parts[0][0] + parts[1][0]).toUpperCase();
|
||||
} else if (emailPart.includes('.')) {
|
||||
const parts = emailPart.split('.');
|
||||
initials = (parts[0][0] + parts[1][0]).toUpperCase();
|
||||
} else {
|
||||
initials = emailPart.substring(0, 2).toUpperCase();
|
||||
}
|
||||
}
|
||||
db.prepare('UPDATE users SET custom_initials = ? WHERE id = ?').run(initials, user.id);
|
||||
}
|
||||
}
|
||||
|
||||
// Neue initials Spalte hinzufügen
|
||||
db.exec("ALTER TABLE users ADD COLUMN initials TEXT");
|
||||
|
||||
// Daten von custom_initials nach initials kopieren
|
||||
db.exec("UPDATE users SET initials = custom_initials");
|
||||
|
||||
logger.info('Migration: initials Spalte hinzugefügt und E-Mail-Daten vorbereitet');
|
||||
}
|
||||
|
||||
// Proposals (Vorschlaege)
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS proposals (
|
||||
@ -536,7 +593,7 @@ async function createDefaultUsers() {
|
||||
const existingUsers = db.prepare('SELECT COUNT(*) as count FROM users').get();
|
||||
|
||||
// Admin-Passwort korrigieren (falls aus .env verschieden)
|
||||
const adminExists = db.prepare('SELECT id, password_hash FROM users WHERE username = ? AND role = ?').get('admin', 'admin');
|
||||
const adminExists = db.prepare('SELECT id, password_hash FROM users WHERE email = ? AND role = ?').get('admin@taskmate.local', 'admin');
|
||||
if (adminExists) {
|
||||
const correctAdminPassword = process.env.ADMIN_PASSWORD || 'admin123';
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren