Add read-only Noya admin panel with assignments and UX polish.
Ship admin auth, user overview, assessments, chats, assignment filters/export, security hardening, and a separate desktop admin shell with clearer assessment answers. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
-- Additive: User.role for admin access control + AuditLog for sensitive admin actions.
|
||||
-- Non-destructive: existing users default to role `user`; no rows deleted.
|
||||
|
||||
ALTER TABLE `users`
|
||||
ADD COLUMN `role` ENUM('user', 'admin') NOT NULL DEFAULT 'user';
|
||||
|
||||
CREATE INDEX `idx_users_role` ON `users`(`role`);
|
||||
|
||||
CREATE TABLE `audit_logs` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`actorUserId` BIGINT UNSIGNED NULL,
|
||||
`action` VARCHAR(64) NOT NULL,
|
||||
`targetUserId` BIGINT UNSIGNED NULL,
|
||||
`targetType` VARCHAR(64) NULL,
|
||||
`targetId` VARCHAR(191) NULL,
|
||||
`metadata` JSON NULL,
|
||||
`ipAddress` VARCHAR(64) NULL,
|
||||
`userAgent` VARCHAR(512) NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_audit_logs_actor_created`(`actorUserId`, `createdAt`),
|
||||
INDEX `idx_audit_logs_action_created`(`action`, `createdAt`),
|
||||
INDEX `idx_audit_logs_target_created`(`targetUserId`, `createdAt`),
|
||||
|
||||
CONSTRAINT `audit_logs_actorUserId_fkey`
|
||||
FOREIGN KEY (`actorUserId`) REFERENCES `users`(`id`)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `audit_logs_targetUserId_fkey`
|
||||
FOREIGN KEY (`targetUserId`) REFERENCES `users`(`id`)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
Reference in New Issue
Block a user