chore: upload parte 2 - assets
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import bcrypt from "bcryptjs";
|
||||
import { neon } from "@neondatabase/serverless";
|
||||
|
||||
const sql = neon(process.env.DATABASE_URL);
|
||||
|
||||
async function resetAdminPassword() {
|
||||
const password = "admin123";
|
||||
const hash = await bcrypt.hash(password, 10);
|
||||
|
||||
console.log("Generated hash:", hash);
|
||||
|
||||
// Update admin user password
|
||||
await sql`UPDATE users SET password_hash = ${hash} WHERE email = 'admin@linse.com'`;
|
||||
|
||||
// Verify the user exists
|
||||
const users = await sql`SELECT id, email, name, role FROM users WHERE email = 'admin@linse.com'`;
|
||||
|
||||
if (users.length > 0) {
|
||||
console.log("Admin user updated:", users[0]);
|
||||
} else {
|
||||
// Create admin user if doesn't exist
|
||||
const newHash = await bcrypt.hash("admin123", 10);
|
||||
await sql`INSERT INTO users (email, password_hash, name, role) VALUES ('admin@linse.com', ${newHash}, 'Administrator', 'admin')`;
|
||||
|
||||
const newUser = await sql`SELECT id FROM users WHERE email = 'admin@linse.com'`;
|
||||
if (newUser.length > 0) {
|
||||
await sql`INSERT INTO user_permissions (user_id, can_view_dashboard, can_view_components, can_view_products, can_view_production, can_view_suppliers, can_view_customers, can_view_stock_history, can_view_stock_take, can_view_logistics, can_view_settings, can_view_financial, can_create, can_edit, can_delete, can_download, sections)
|
||||
VALUES (${newUser[0].id}, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, ARRAY['dashboard', 'components', 'products', 'production', 'suppliers', 'customers', 'stock-history', 'stock-take', 'logistics', 'settings'])`;
|
||||
console.log("Admin user created with permissions");
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Done!");
|
||||
}
|
||||
|
||||
resetAdminPassword().catch(console.error);
|
||||
Reference in New Issue
Block a user