-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_create_admin_user.sql
More file actions
58 lines (52 loc) · 1.92 KB
/
03_create_admin_user.sql
File metadata and controls
58 lines (52 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- ==========================================
-- CREATE DEFAULT ADMIN USER
-- ==========================================
-- IMPORTANT: Run this to create the first admin user
-- CHANGE ACCORDINGLY: Update email and password hash
-- ==========================================
-- SECURITY WARNING
-- ==========================================
-- The password below is 'Admin@123' (hashed with bcrypt)
-- CHANGE ACCORDINGLY: After first login, change this password immediately!
-- Or better, update the password here before running this script
-- To generate a new bcrypt hash for a different password:
-- Use Python:
-- from passlib.context import CryptContext
-- pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
-- print(pwd_context.hash("YourNewPassword"))
-- ==========================================
-- INSERT ADMIN USER
-- ==========================================
-- CHANGE ACCORDINGLY: Update email, full_name, and password
INSERT INTO users (email, full_name, hashed_password, role, is_protected)
VALUES (
'admin@example.com', -- CHANGE ACCORDINGLY: Your admin email
'System Administrator', -- CHANGE ACCORDINGLY: Admin name
'$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5eU7L/vK5uiKW', -- CHANGE ACCORDINGLY: Password hash for 'Admin@123'
'admin', -- Role: admin (DO NOT CHANGE)
1 -- Protected: Yes (prevents deletion via UI)
);
-- Verify admin user was created
SELECT
id,
email,
full_name,
role,
is_protected,
created_at
FROM users
WHERE role = 'admin';
-- ==========================================
-- NOTES
-- ==========================================
-- Default credentials (CHANGE IMMEDIATELY):
-- Email: admin@example.com
-- Password: Admin@123
--
-- To change password after first login:
-- 1. Login with default credentials
-- 2. Go to Profile page
-- 3. Update password
--
-- Or update in database directly with new hash
-- ==========================================