Skip to content

[codex] simplify TokChat user roles - #12

Merged
yaojingang merged 1 commit into
mainfrom
codex/simplify-tokchat-user-roles
Jun 14, 2026
Merged

[codex] simplify TokChat user roles#12
yaojingang merged 1 commit into
mainfrom
codex/simplify-tokchat-user-roles

Conversation

@yaojingang

Copy link
Copy Markdown
Owner

Summary

  • Simplify TokChat user-management role options to 普通用户 and 系统管理员.
  • Change the default frontend user role from sales_rep to user.
  • Normalize legacy sales_rep and sales_manager rows to user during database initialization.
  • Keep existing admin user-role records displayed as 系统管理员.
  • Add backend role validation/normalization for create, update, and list filters.

Validation

  • php -l tools/tokchat/admin.php
  • php -l tools/tokchat/api/users.php
  • php -l tools/tokchat/api/db.php
  • temporary SQLite check: seeded users use user; legacy sales_manager is migrated to user
  • git diff --check

@yaojingang
yaojingang merged commit 81841e8 into main Jun 14, 2026
1 check passed
@yaojingang
yaojingang deleted the codex/simplify-tokchat-user-roles branch June 14, 2026 23:17
@augmentcode

augmentcode Bot commented Jun 14, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR simplifies TokChat’s user-role model to just user (普通用户) and admin (系统管理员).

Changes:

  • Updates the admin UI to only offer the two roles and sets the default user role to user.
  • Normalizes legacy sales_rep/sales_manager rows to user during DB initialization and updates demo seed data accordingly.
  • Adds backend role normalization/validation for user list filters and for create/update requests.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread tools/tokchat/api/db.php
// 字段已存在,忽略
}

normalizeLegacyUserRoles($db);

@augmentcode augmentcode Bot Jun 14, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normalizeLegacyUserRoles($db) is executed without a try/catch, so initDatabase() will fail hard if an existing users table predates the role column (or otherwise lacks it). Consider guarding this update similarly to the other migration-style ALTER TABLE blocks so upgrades don’t break on older/corrupt schemas.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant