backen: jwt

This commit is contained in:
2025-09-30 16:38:37 +07:00
parent 8b2dff8d1d
commit 5be0f5407b
396 changed files with 33377 additions and 4851 deletions

View File

@@ -64,8 +64,6 @@ CREATE TABLE users (
email VARCHAR(255) NULL UNIQUE,
line_id VARCHAR(255) NULL,
password_hash VARCHAR(255) NOT NULL,
email VARCHAR(255) NULL UNIQUE,
line_id VARCHAR(255) NULL,
org_id INT NULL, -- link to organizations for ADMIN scope
is_active TINYINT(1) NOT NULL DEFAULT 1,
failed_attempts INT NOT NULL DEFAULT 0,

View File

@@ -117,7 +117,7 @@ WHERE r.role_code='VIEWER';
-- 3.4 Initial SUPER_ADMIN user (set real password on first login)
INSERT INTO users (username, password_hash, email, is_active)
VALUES ('superadmin', '$2y$10$0kjBMxWq7E4G7P.dc8r5i.cjiPBiup553AsFpDfxUt31gKg9h/udq, 'superadmin@example.com', 1)
VALUES ('superadmin', '$2y$10$0kjBMxWq7E4G7P.dc8r5i.cjiPBiup553AsFpDfxUt31gKg9h/udq', 'superadmin@example.com', 1)
ON DUPLICATE KEY UPDATE email=VALUES(email), is_active=VALUES(is_active);
INSERT IGNORE INTO user_roles (user_id, role_id)

View File

@@ -4,7 +4,7 @@
SET NAMES utf8mb4;
SET time_zone = '+00:00';
SET FOREIGN_KEY_CHECKS=0;
-- ใช้ IF NOT EXISTS ป้องกันรันซ้ำ
CREATE TABLE IF NOT EXISTS password_resets (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS password_resets (
FOREIGN KEY (user_id) REFERENCES users(user_id)
ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SET FOREIGN_KEY_CHECKS=1;
-- (ออปชัน) กำจัด token ที่หมดอายุอัตโนมัติด้วย EVENT (หากเปิด event_scheduler)
-- CREATE EVENT IF NOT EXISTS ev_prune_password_resets
-- ON SCHEDULE EVERY 1 DAY