Commit Graph

95 Commits

Author SHA1 Message Date
feitianbubu 02aacb38a2 feat: add user created_at and last_login_at 2026-04-25 12:44:44 +08:00
CaIon 59c582d13c fix: harden token auth error handling to prevent info leakage
- Create model/errors.go to centralize all sentinel errors
- ValidateAccessToken now returns error to distinguish DB failures
- ValidateUserToken uses unified ErrTokenInvalid for all auth failures
  (expired/exhausted/disabled/not-found) to prevent token enumeration
- authHelper and TokenAuthReadOnly use i18n messages instead of
  hardcoded Chinese strings
- All err.Error() removed from user-facing responses; DB errors logged
  server-side and return generic "contact admin" message (HTTP 500)
- Migrate ErrRedeemFailed, ErrTwoFANotEnabled to model/errors.go
2026-04-12 17:39:00 +08:00
CaIon 2819e3a1d1 fix: improve login error handling to distinguish database errors from auth failures
ValidateAndFill now checks the DB query result and returns sentinel errors
(ErrDatabase, ErrInvalidCredentials, ErrUserEmptyCredentials) instead of
hardcoded Chinese strings. The controller maps each sentinel to the
appropriate i18n message, so users see "please contact admin" on DB errors
instead of a misleading "wrong password" message. Non-DB errors still
return a unified vague response to avoid leaking user existence.
2026-04-12 17:11:20 +08:00
CaIon 040e8c1da8 feat: replace quota input with amount-first UI and atomic quota adjustment
- Refactor token, redemption, and user quota inputs to prioritize monetary
  amount entry, with raw quota input collapsed by default
- Add atomic quota adjustment modal for users with add/subtract/override modes,
  bypassing batch update queue for immediate DB consistency
- Make user quota fields readonly in edit form; all modifications go through
  the dedicated adjust-quota modal via POST /api/user/manage
- Add DecreaseUserQuota `db` parameter for direct DB writes, matching
  IncreaseUserQuota behavior
- Support negative quota display in amount conversion helpers
- Add i18n keys for all new UI strings across all locales
2026-04-09 22:44:53 +08:00
CaIon b85192590b fix: handle nil setting in user retrieval from database 2026-02-24 23:46:46 +08:00
Calcium-Ion 89c0b7902b Merge pull request #2998 from seefs001/fix/pr-2900
Fix/pr 2900
2026-02-24 13:35:05 +08:00
Seefs 262ece0d71 fix: check oauthUser.Username length 2026-02-24 13:26:19 +08:00
Seefs 62856666c4 feat: move user bindings to dedicated management modal 2026-02-23 14:51:55 +08:00
CaIon a94142f603 fix(oauth): enhance error handling and transaction management for OAuth user creation and binding
- Improve error handling in DeleteCustomOAuthProvider to log and return errors when fetching binding counts.
- Refactor user creation and OAuth binding logic to use transactions for atomic operations, ensuring data integrity.
- Add unique constraints to UserOAuthBinding model to prevent duplicate bindings.
- Enhance GitHub OAuth provider error logging for non-200 responses.
- Update AccountManagement component to provide clearer error messages on API failures.
2026-02-05 21:48:05 +08:00
CaIon 424595e620 feat(oauth): migrate GitHub user identification from login to numeric ID 2026-02-05 20:30:48 +08:00
StageDog 18bf8aad60 fix: IsDiscordIdAlreadyTaken 应该检查软删除记录 2025-11-23 00:07:34 +08:00
StageDog 352801cd35 feat: 关联 discord 账号 2025-11-22 18:38:24 +08:00
Seefs 5010f2d004 format: package name -> github.com/QuantumNous/new-api (#2017) 2025-10-11 15:30:09 +08:00
CaIon 6ca88d1699 fix(models): increase varchar length for TaskID and Username fields #1905 2025-09-29 16:45:46 +08:00
F。 d0d6168e2f 顶栏和侧边栏管理
增加用户体验
2025-08-31 07:07:40 +08:00
CaIon c9e9a24e99 refactor: centralize logging and update resource initialization
This commit refactors the logging mechanism across the application by replacing direct logger calls with a centralized logging approach using the `common` package. Key changes include:

- Replaced instances of `logger.SysLog` and `logger.FatalLog` with `common.SysLog` and `common.FatalLog` for consistent logging practices.
- Updated resource initialization error handling to utilize the new logging structure, enhancing maintainability and readability.
- Minor adjustments to improve code clarity and organization throughout various modules.

This change aims to streamline logging and improve the overall architecture of the codebase.
2025-08-14 21:10:04 +08:00
CaIon 97ea8b6560 refactor: Introduce pre-consume quota and unify relay handlers
This commit introduces a major architectural refactoring to improve quota management, centralize logging, and streamline the relay handling logic.

Key changes:
- **Pre-consume Quota:** Implements a new mechanism to check and reserve user quota *before* making the request to the upstream provider. This ensures more accurate quota deduction and prevents users from exceeding their limits due to concurrent requests.

- **Unified Relay Handlers:** Refactors the relay logic to use generic handlers (e.g., `ChatHandler`, `ImageHandler`) instead of provider-specific implementations. This significantly reduces code duplication and simplifies adding new channels.

- **Centralized Logger:** A new dedicated `logger` package is introduced, and all system logging calls are migrated to use it, moving this responsibility out of the `common` package.

- **Code Reorganization:** DTOs are generalized (e.g., `dalle.go` -> `openai_image.go`) and utility code is moved to more appropriate packages (e.g., `common/http.go` -> `service/http.go`) for better code structure.
2025-08-14 20:05:06 +08:00
wzxjohn df69147da9 fix: for AI review problems 2025-07-10 20:55:43 +08:00
wzxjohn 81d474ba3c feat: add stripe pay api support 2025-07-10 16:29:38 +08:00
Xiangyuan-liu db98c0f4b1 refactor: log params and channel params
refactor: log params and channel params
2025-07-07 14:26:37 +08:00
Xiangyuan-liu b206a7c683 feat: 优化分页组件 2025-06-25 18:42:19 +08:00
Apple\Apple 1f6ec0174a feat: add admin-only "remark" support for users
* backend
  - model: add `Remark` field (varchar 255, `json:"remark,omitempty"`); AutoMigrate handles schema change automatically
  - controller:
    * accept `remark` on user create/update endpoints
    * hide remark from regular users (`GetSelf`) by zero-ing the field before JSON marshalling
    * clarify inline comment explaining the omitempty behaviour

* frontend (React / Semi UI)
  - AddUser.js & EditUser.js: add “Remark” input for admins
  - UsersTable.js:
    * remove standalone “Remark” column
    * show remark as a truncated Tag next to username with Tooltip for full text
    * import Tooltip component
  - i18n: reuse existing translations where applicable

This commit enables administrators to label users with private notes while ensuring those notes are never exposed to the users themselves.
2025-06-16 03:20:54 +08:00
CaIon 4371717c78 fix: Resolving conflicts caused by mixing multiple databases 2025-06-14 17:51:05 +08:00
skynono bb596ae8e6 feat: add original password verification when changing password 2025-05-06 14:28:27 +08:00
creamlike1024 fea6f17e80 fix: GetMaxUserId use Unscope, close #987 2025-04-25 16:13:11 +08:00
CaIon f33ebc8e2c feat: Implement system setup functionality 2025-04-03 18:57:15 +08:00
wzxjohn bdb1a2fcb9 feat: add oidc support 2025-03-11 15:52:03 +08:00
1808837298@qq.com d04d78a116 refactor: Enhance user context and quota management
- Add new context keys for user-related information
- Modify user cache and authentication middleware to populate context
- Refactor quota and notification services to use context-based user data
- Remove redundant database queries by leveraging context information
- Update various components to use new context-based user retrieval methods
2025-02-25 20:56:16 +08:00
1808837298@qq.com 1ae0a38485 refactor: Optimize user caching and token retrieval methods 2025-02-19 15:12:26 +08:00
1808837298@qq.com 83e161a1d4 refactor: Simplify root user notification and remove global email variable
- Remove global `RootUserEmail` variable
- Modify channel testing and user notification methods to use `GetRootUser()`
- Update user cache and notification service to use more consistent user base type
- Add new channel test notification type
2025-02-18 15:59:17 +08:00
1808837298@qq.com 0fcd243f56 feat: Add user notification settings with quota warning and multiple notification methods
- Implement user notification settings with email and webhook options
- Add new user settings for quota warning threshold and notification preferences
- Create backend API and database support for user notification configuration
- Enhance frontend personal settings with notification configuration UI
- Support custom notification email and webhook URL
- Add service layer for sending user notifications
2025-02-18 14:54:21 +08:00
1808837298@qq.com aa2ac4766e Enhance user search functionality to support ID and keyword searches. Updated query conditions to allow searching by user ID alongside username, email, and display name. Improved handling of numeric and string keywords in search queries. 2025-01-06 15:20:38 +08:00
CalciumIon 7fec5fa1b3 feat: enhance user search functionality with pagination support
- Updated SearchUsers function to include pagination parameters (startIdx and num) for improved user search results.
- Modified API response structure to return paginated data, including total user count and current page information.
- Adjusted UsersTable component to handle pagination and search parameters, ensuring a seamless user experience.
- Added internationalization support for new search functionality in the UI.
2024-12-31 15:02:59 +08:00
CalciumIon 5a39d2e171 feat: enhance user management and pagination features #518
- Updated GetAllUsers function to return total user count along with paginated results, improving data handling in user retrieval.
- Modified GetAllUsers API endpoint to accept page size as a parameter, allowing for dynamic pagination.
- Enhanced UsersTable component to support customizable page sizes and improved pagination logic.
- Added error handling for empty username and password in AddUser component.
- Updated LogsTable component to display pagination information in a user-friendly format.
2024-12-31 14:52:55 +08:00
CalciumIon aefd53b683 refactor: token cache logic 2024-12-30 17:10:48 +08:00
CalciumIon c6ae827385 refactor: remove redundant group column handling in user queries 2024-12-29 17:02:30 +08:00
CalciumIon 966cdc1f7f refactor: user cache logic 2024-12-29 16:50:26 +08:00
borland ad15c0cb38 Update user.go 2024-12-22 00:03:00 +08:00
borland 57a24bed51 Update user.go 2024-12-22 00:02:28 +08:00
seefs001 12de1faca9 feat: integrate Linux DO OAuth authentication 2024-11-10 23:56:22 +08:00
1808837298@qq.com fd2379e807 fix: 第三方登录注销 #500 2024-09-25 17:13:28 +08:00
1808837298@qq.com 05f35fd024 feat: 不自动生成系统访问令牌 2024-09-25 16:31:25 +08:00
1808837298@qq.com a50d2e6836 fix: error user role 2024-09-24 17:49:57 +08:00
CalciumIon 1dfa18ab9a fix: email login 2024-07-09 21:36:31 +08:00
CalciumIon ea72b9c960 feat: able to use email to login (close #343,#348) 2024-07-08 16:28:56 +08:00
1808837298@qq.com 2fed1a1506 fix: update user (#230) 2024-05-08 16:46:06 +08:00
CaIon 03f26006a1 fix: update user 2024-04-24 19:40:29 +08:00
iszcz e00a468464 用户管理页新增分组查询 2024-04-20 02:13:11 +08:00
CaIon b26e53bcd4 feat: update cache 2024-04-18 20:30:17 +08:00
CaIon dac6849603 feat: update cache #204 2024-04-18 20:23:44 +08:00