Fix admin route access and backend configuration
- Added /admin redirect to login page in nginx config - Fixed backend server.js route ordering for proper admin handling - Updated authentication middleware and routes - Added user management routes - Configured PostgreSQL integration - Updated environment configuration
This commit is contained in:
48
backend/setup-database.sql
Normal file
48
backend/setup-database.sql
Normal file
@@ -0,0 +1,48 @@
|
||||
-- Create adminusers table if it doesn't exist
|
||||
CREATE TABLE IF NOT EXISTS adminusers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
passwordhash TEXT NOT NULL,
|
||||
role VARCHAR(50) DEFAULT 'admin',
|
||||
createdat TIMESTAMP DEFAULT NOW(),
|
||||
lastlogin TIMESTAMP
|
||||
);
|
||||
|
||||
-- Insert temporary admin user
|
||||
-- Password: TempAdmin2024!
|
||||
-- Bcrypt hash generated with 10 salt rounds
|
||||
INSERT INTO adminusers (email, name, passwordhash, role, createdat)
|
||||
VALUES (
|
||||
'admin@skyartshop.com',
|
||||
'Temporary Admin',
|
||||
'$2b$10$YvK5rQE4nHjZH5tVFZ1lNu5iK7Jx/lMQXZvhGEg8sK1vF0N3wL5oG',
|
||||
'superadmin',
|
||||
NOW()
|
||||
)
|
||||
ON CONFLICT (email) DO UPDATE
|
||||
SET passwordhash = EXCLUDED.passwordhash,
|
||||
name = EXCLUDED.name,
|
||||
role = EXCLUDED.role;
|
||||
|
||||
-- Create appusers table for public users (if needed)
|
||||
CREATE TABLE IF NOT EXISTS appusers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
passwordhash TEXT NOT NULL,
|
||||
createdat TIMESTAMP DEFAULT NOW(),
|
||||
lastlogin TIMESTAMP
|
||||
);
|
||||
|
||||
-- Create sessions table for express-session
|
||||
CREATE TABLE IF NOT EXISTS session (
|
||||
sid VARCHAR NOT NULL COLLATE "default",
|
||||
sess JSON NOT NULL,
|
||||
expire TIMESTAMP(6) NOT NULL,
|
||||
PRIMARY KEY (sid)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS IDX_session_expire ON session (expire);
|
||||
|
||||
SELECT 'Database setup complete!' as status;
|
||||
Reference in New Issue
Block a user