mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-23 23:18:12 +02:00
3 files changed
+35
-4
No files matched your search
@@ -14,10 +14,6 @@ run = ["npm", "run", "start"]
|
|||||||
localPort = 5000
|
localPort = 5000
|
||||||
externalPort = 80
|
externalPort = 80
|
||||||
|
|
||||||
[[ports]]
|
|
||||||
localPort = 35739
|
|
||||||
externalPort = 3002
|
|
||||||
|
|
||||||
[[ports]]
|
[[ports]]
|
||||||
localPort = 40537
|
localPort = 40537
|
||||||
externalPort = 3000
|
externalPort = 3000
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import passport from "./auth";
|
|||||||
import { registerRoutes } from "./routes";
|
import { registerRoutes } from "./routes";
|
||||||
import { setupVite, serveStatic, log } from "./vite";
|
import { setupVite, serveStatic, log } from "./vite";
|
||||||
import { schedulerService } from "./services/scheduler";
|
import { schedulerService } from "./services/scheduler";
|
||||||
|
import { ensureAdminUserExists } from "./init-admin";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@@ -94,6 +95,10 @@ app.use((req, res, next) => {
|
|||||||
// this serves both the API and the client.
|
// this serves both the API and the client.
|
||||||
// It is the only port that is not firewalled.
|
// It is the only port that is not firewalled.
|
||||||
const port = parseInt(process.env.PORT || '5000', 10);
|
const port = parseInt(process.env.PORT || '5000', 10);
|
||||||
|
|
||||||
|
// Initialiser l'utilisateur admin par défaut avant de démarrer le serveur
|
||||||
|
await ensureAdminUserExists();
|
||||||
|
|
||||||
server.listen({
|
server.listen({
|
||||||
port,
|
port,
|
||||||
host: "0.0.0.0",
|
host: "0.0.0.0",
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { storage } from "./storage";
|
||||||
|
import bcrypt from "bcrypt";
|
||||||
|
|
||||||
|
export async function ensureAdminUserExists() {
|
||||||
|
try {
|
||||||
|
const adminUser = await storage.getUserByUsername("admin");
|
||||||
|
|
||||||
|
if (!adminUser) {
|
||||||
|
console.log("🔧 Création de l'utilisateur admin par défaut...");
|
||||||
|
|
||||||
|
const hashedPassword = await bcrypt.hash("admin", 10);
|
||||||
|
|
||||||
|
await storage.createUser({
|
||||||
|
username: "admin",
|
||||||
|
password: hashedPassword,
|
||||||
|
role: "admin",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("✅ Utilisateur admin créé avec succès");
|
||||||
|
console.log(" Username: admin");
|
||||||
|
console.log(" Password: admin");
|
||||||
|
console.log(" ⚠️ IMPORTANT: Changez ce mot de passe immédiatement !");
|
||||||
|
} else {
|
||||||
|
console.log("✓ Utilisateur admin existe déjà");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("❌ Erreur lors de la vérification/création de l'utilisateur admin:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user