Commit graph

66 commits

Author SHA1 Message Date
Max
538f76e317 Add features query endpoint to user API
- Introduced a new endpoint `GET /features` to allow authenticated users to query available features.
- This addition enhances the user experience by providing access to feature-related information directly through the API.
2025-10-29 15:32:36 +08:00
Max
481a6edbd5 Enhance team invitation functionality with locale support
- Updated the invitation resend process to accept a locale parameter, allowing for locale-specific email formatting and invitation link generation.
- Modified the `teamInvitationResend` function to include locale handling, ensuring proper configuration based on the user's locale.
- Enhanced the `toString` utility function to support time formatting based on locale, improving date presentation in emails.
- Added new utility functions for locale-specific time formatting, ensuring consistent user experience across different regions.
- Expanded tests to validate the new locale handling in invitation processes, ensuring comprehensive coverage for various scenarios.
2025-10-29 09:28:55 +08:00
Max
7549a890e5 Refactor team configuration tests to remove uploader and avatar agent assertions
- Removed assertions for the uploader and avatar agent fields in the team configuration tests, as these fields are no longer preserved in the public configuration.
- Updated the GetTeamConfigPublic function to reflect the changes in the TeamConfig structure, ensuring only relevant fields are included in the public configuration.
- Adjusted test cases to maintain coverage while aligning with the updated configuration structure.
2025-10-28 17:22:44 +08:00
Max
376befc21b Add Yao member profile support in OIDC user info
- Enhanced the OIDC user info structure to include Yao member profile information, such as member ID, display name, bio, avatar, and email.
- Updated the SignIDToken and MakeOIDCUserInfo functions to incorporate member details if available, improving team context handling.
- Refactored the issueTokens function to accept a new IssueTokensParams structure, streamlining token issuance with team and member context.
- Adjusted login functions to retrieve and pass member profile data during token issuance, ensuring comprehensive user context in authentication flows.
2025-10-28 16:55:06 +08:00
Max
bf452ba1d3 Add member profile retrieval functionality
- Introduced a new endpoint `GET /teams/:team_id/members/:member_id/profile` to allow users to retrieve member profile information, including display name, bio, avatar, and email.
- Implemented the `GinMemberGetProfile` handler to process profile retrieval requests with appropriate authentication and error handling.
- Added business logic in `memberGetProfile` to ensure only authenticated users can access their own profile data.
- Expanded test cases in `TestMemberProfileGet` to validate various scenarios for profile retrieval, ensuring comprehensive coverage for authentication and data validation.
2025-10-28 16:18:52 +08:00
Max
af02a21f65 Implement member profile update functionality
- Added a new endpoint `PUT /teams/:team_id/members/:member_id/profile` to allow members to update their profile information, including display name, bio, avatar, and email.
- Introduced `UpdateMemberProfileRequest` structure to handle profile update requests.
- Enhanced the `GinMemberUpdateProfile` handler to process profile updates with appropriate validation and error handling.
- Implemented business logic in `memberUpdateProfile` to ensure only the member can update their own profile.
- Expanded test cases to validate the new profile update functionality, ensuring comprehensive coverage for various update scenarios.
2025-10-28 11:49:01 +08:00
Max
b2c7ddde19 Add new endpoint for file content retrieval
- Introduced a new API endpoint `GET /file/:uploaderID/:fileID/content` to facilitate the retrieval of file content based on uploader ID and file ID.
- This addition enhances the user capabilities for accessing file data within the application.
2025-10-28 09:28:05 +08:00
Max
8ffa767dfe Add logo support to team creation and update functionality
- Enhanced the team creation and update processes to include an optional logo field, allowing teams to have custom logos.
- Updated the CreateTeamRequest and UpdateTeamRequest structures to accommodate the new logo field.
- Modified the GinTeamCreate and GinTeamUpdate handlers to handle logo data appropriately.
- Expanded test cases for team creation and updates to validate logo handling, ensuring comprehensive coverage for scenarios involving logos.
2025-10-27 17:46:25 +08:00
Max
7572f99ba0 Enhance robot member functionality with avatar support
- Added avatar field to CreateRobotMemberRequest and UpdateRobotMemberRequest structures, allowing for avatar URL or file ID during member creation and updates.
- Updated GinMemberCreateRobot and GinMemberUpdateRobot handlers to process avatar information, ensuring it is included in the member data.
- Expanded test cases for member creation and updates to validate avatar handling, including scenarios for updating only the avatar without affecting other fields.
- Enhanced team configuration tests to verify preservation of uploader and avatar agent fields, improving overall test coverage and reliability.
2025-10-27 16:45:10 +08:00
Max
1e01ed768e Implement robot member update functionality with comprehensive validation
- Added the `UpdateRobotMember` method to handle updates for robot members, including validation for member existence, type checks, and email uniqueness.
- Introduced a new `UpdateRobotMemberRequest` structure to facilitate updates via the API, allowing for modifications to various fields such as `robot_email`, `status`, and `autonomous_mode`.
- Enhanced the `GinMemberUpdateRobot` handler to process update requests, ensuring proper authentication and error handling for various scenarios.
- Expanded test coverage with new test cases for the robot member update functionality, validating successful updates, error conditions, and edge cases.
- Refactored existing member management logic to integrate the new update capabilities, improving overall system robustness and user experience.
2025-10-27 12:05:11 +08:00
Max
7de562f80d Update robot member functionality with new fields and validation
- Introduced the `robot_email`, `authorized_senders`, and `email_filter_rules` fields to the robot member model, enhancing the configuration options for robot members.
- Updated the member creation and existence check logic to ensure the uniqueness of `robot_email` globally, improving data integrity.
- Refactored API endpoints and request/response structures to accommodate the new fields, ensuring consistency across the member management system.
- Enhanced test cases to validate the new robot member features, including scenarios for email uniqueness and configuration updates, improving overall test coverage and reliability.
2025-10-27 11:34:07 +08:00
Max
772c00e095 Enhance member listing functionality with advanced filtering and sorting
- Introduced a new MemberListRequest structure to support advanced filtering options such as status, member_type, role_id, email, and display_name.
- Updated the GinMemberList handler to parse and validate query parameters, improving user experience with clearer error messages for invalid inputs.
- Enhanced the memberList function to handle advanced filtering and sorting, allowing for more flexible and efficient member retrieval.
- Added comprehensive test cases to validate new filtering and sorting functionalities, ensuring robust coverage and reliability in member listing scenarios.
- Refactored existing member response structures to include new fields and improve data representation.
2025-10-26 14:10:04 +08:00
Max
420a17f844 Enhance member model and team management with is_owner field
- Added the is_owner field to the member model to indicate if a member is the team owner, improving clarity and performance for queries related to team ownership.
- Updated the team creation process to automatically set the is_owner field for the creator of the team, ensuring accurate member status upon creation.
- Refactored related tests to verify the correct assignment of the is_owner field, enhancing test coverage and reliability in team membership scenarios.
- Removed redundant permission and restriction fields from the member model to streamline the data structure and improve maintainability.
2025-10-26 12:25:15 +08:00
Max
5f6f8d7911 Enhance member management with member_id and email checks
- Introduced member_id as a unique identifier for members, improving data integrity and consistency across member operations.
- Updated member-related functions to utilize member_id instead of internal IDs, enhancing API usability and clarity.
- Implemented email existence checks for team members, allowing for better validation during member creation and updates.
- Refactored existing tests to accommodate changes in member identification and email validation, ensuring comprehensive coverage and reliability.
- Added new API endpoint for checking if an email exists within a team, improving user experience during member management.
2025-10-26 09:49:45 +08:00
Max
fd10a058b1 Implement robot member creation and validation
- Introduced a new endpoint for creating robot members, enhancing the member model to include fields specific to robots such as email, system prompt, and autonomous mode.
- Refactored existing member creation logic to accommodate robot-specific requirements and ensure email uniqueness within teams.
- Updated request and response structures to support the new robot member functionality, improving API consistency.
- Added comprehensive test cases to validate the new robot member creation process, including scenarios for required fields, duplicate emails, and invalid inputs.
2025-10-26 09:04:22 +08:00
Max
ddf8fd7a32 Refactor test utilities and enhance access token handling
- Introduced ObtainAccessTokenWithRootPermission function to streamline the creation of test users with root permissions, ensuring consistent access token generation for tests.
- Updated various test cases to utilize the new function, improving clarity and reducing redundancy in access token acquisition.
- Enhanced team configuration retrieval to expose public settings while hiding sensitive information, improving security in API responses.
2025-10-25 13:26:51 +08:00
Max
f31b3f5882 Update member model to include profile fields and enhance invitation handling
- Added display_name, bio, and email fields to the member model for improved team-specific identity.
- Updated team invitation creation and acceptance logic to handle new profile fields, ensuring proper data management and user experience.
- Implemented logic to copy user profile fields when creating or updating members, enhancing data consistency.
2025-10-23 19:40:29 +08:00
Max
b9e71823ca Add current team retrieval endpoint and refactor team access checks 2025-10-23 17:50:32 +08:00
Max
5d6f346601 Update team invitation handling and user invitation acceptance logic
- Refactored the team invitation creation function to utilize the new authorized package for improved user authentication checks.
- Enhanced the invitation acceptance logic to include the user ID of the person who updated the invitation, improving tracking and accountability.
- Adjusted the invitation data preparation to incorporate user-specific scopes, ensuring proper permissions are applied during invitation processing.
2025-10-23 11:22:10 +08:00
Max
cd9c52fe33 Normalize request paths in ACL checks and add path normalization utility
- Implemented path normalization in the ACL enforcement logic to ensure consistent matching by removing trailing slashes from request paths.
- Introduced a new utility function, normalizePath, to handle path normalization across various components.
- Updated endpoint matching and public endpoint checks to utilize the normalized paths, improving access decision accuracy.
- Enhanced team and member creation logic to include a new field, __yao_team_id, for better data management.
2025-10-23 10:48:53 +08:00
Max
cc181a52f6 Enhance ACL configuration and enforcement with path prefix support
- Updated ACL configuration to include a PathPrefix field, allowing for dynamic path stripping from request URLs.
- Enhanced ACL enforcement logic to log the configured path prefix and adjust request paths accordingly during access checks.
- Improved logging throughout the enforcement process to provide clearer insights into access decisions and scope matching.
- Registered built-in scopes for temporary access tokens, enhancing flexibility in access control for specific endpoints.
- Updated scope management to support constraints for matched scopes, improving granularity in access control configurations.
2025-10-22 19:19:30 +08:00
Max
b1db5505ea Update team model and creation logic to support role management
- Added role_id field to the team model for specifying team owner roles.
- Enhanced team creation logic to set default role_id based on team configuration if not provided.
- Updated tests to reflect changes in team type and role handling, ensuring accurate assertions.
- Improved documentation for team configuration to clarify default role settings for team creators.
2025-10-20 17:00:33 +08:00
Max
140368a69b Refactor session cookie handling in user entry logic
- Updated GinVerifyInvite function to replace session cookie sending with a new SendLoginCookies function, improving clarity in cookie management during user login processes.
- Enhanced handling of login responses to better accommodate different user statuses, streamlining the authentication flow.
2025-10-17 13:33:47 +08:00
Max
5437ceec7d Enhance user registration status handling during third-party login
- Updated the LoginThirdParty function to determine user status based on invitation requirements, setting it to "pending_invite" if an invite is required.
- Improved user data mapping to reflect the new status logic, enhancing the user experience during the registration process.
2025-10-17 09:41:41 +08:00
Max
5d1b665457 Enhance user authentication with Remember Me functionality
- Added Remember Me flag to LoginContext and AuthorizedInfo structures to support extended session management.
- Updated GetAuthorizedInfo function to retrieve Remember Me state from the context.
- Modified token issuance logic to accommodate Remember Me settings, adjusting token expiration durations accordingly.
- Preserved Remember Me state during login and team selection processes, improving user experience and session persistence.
2025-10-17 09:31:30 +08:00
Max
9a2a636314 Add invitation model and related functionality
- Introduced the invitation model in bindata.go, including the new invitation.mod.yao file.
- Updated system models to include the invitation model for better integration.
- Added invitation code related error handling in default.go, enhancing user experience during invitation processes.
- Implemented invitation code management methods in the user provider interface, allowing for creation, usage, and deletion of invitation codes.
- Enhanced entry configuration to support invitation code verification, improving the user registration flow.
- Added a new endpoint for verifying invitation codes in user routing, streamlining the invitation redemption process.
2025-10-16 19:08:54 +08:00
Max
c58bc8c4fe Add logout functionality and expose refresh token retrieval
- Implemented GinLogout function to handle user logout, including revoking access and refresh tokens, clearing authentication cookies, and returning a success response.
- Added public method GetRefreshToken to retrieve the refresh token from the request, enhancing token management.
- Updated user routing to link the logout endpoint to the new GinLogout function, improving the user authentication flow.
2025-10-16 14:53:49 +08:00
Max
a8159a0e90 Add OTP resend functionality for user verification
- Implemented GinSendOTP function to handle resending OTP verification codes for user entry.
- Added EntrySendOTPResponse type to structure the response for OTP requests, including OTP ID and expiration time.
- Updated user routing to include a new endpoint for OTP requests, enhancing the user authentication flow.
2025-10-16 14:35:48 +08:00
Max
48f531cf82 Update asset modification times and enhance user authentication flow
- Updated modification times for various asset files in bindata.go to reflect recent changes.
- Enhanced user authentication by adding support for custom claims in the context during authorization, improving flexibility in handling user data.
- Refactored entry verification logic to generate and send OTPs for user registration, streamlining the registration process and improving user experience.
- Introduced new status handling for user accounts, ensuring proper feedback for pending, unverified, and disabled accounts during login attempts.
2025-10-16 10:28:00 +08:00
Max
481323104a Implement deep copy for entry configuration to prevent global config corruption
- Added a new function, createPublicEntryConfig, to create a deep copy of EntryConfig without sensitive data, ensuring that global configuration remains intact when returning public config.
- Updated entry verification logic to utilize EntryVerificationStatus for clearer status handling during user verification.
- Enhanced tests to verify that the global config is not modified after multiple requests for public entry configuration, addressing a critical bug related to captcha secret exposure.
2025-10-15 19:32:40 +08:00
Max
c4ecda54e9 Refactor captcha handling in tests and core functionality
- Updated captcha test cases to utilize the new CaptchaGet function for retrieving captcha answers, improving test reliability.
- Refactored CaptchaMake and CaptchaValidate functions to leverage a new utils package for better encapsulation and maintainability.
- Enhanced error handling and logging in captcha-related processes, contributing to a more robust user experience during authentication.
- Streamlined the captcha generation process by integrating with the utils.captcha package, ensuring consistency across the codebase.
2025-10-15 15:43:16 +08:00
Max
d1a9e5c892 Refactor user authentication to unify entry configuration handling
- Renamed and updated functions and tests to replace 'login' terminology with 'entry', reflecting the unified handling of login and registration processes.
- Removed deprecated login configuration functions and structures, streamlining the codebase.
- Enhanced test coverage for entry configuration retrieval and validation, ensuring comprehensive testing of the new unified approach.
- Improved error handling and logging for entry configuration scenarios, contributing to a better user experience during authentication.
2025-10-15 11:16:54 +08:00
Max
b43a38b387 Refactor user configuration to unify login and registration handling
- Replaced separate register configurations with a unified entry configuration that combines login and registration settings.
- Updated related functions and structures to support the new entry configuration, enhancing the user authentication process.
- Removed deprecated register configuration handling and endpoints, streamlining the codebase.
- Improved error handling for missing entry configurations, ensuring better user experience during authentication.
2025-10-15 09:58:37 +08:00
Max
484ed8d899 Enhance user registration and configuration handling
- Added support for processing environment variables in both register and form configurations, improving flexibility and configurability.
- Introduced a new MessengerConfig structure for handling messenger-related settings in the register configuration.
- Updated the RegisterConfig structure to include ThirdParty and InviteRequired fields, enhancing user registration options.
- Refactored the registration endpoint to retrieve configuration details, ensuring a more robust registration process.
- Implemented logging for missing environment variables to aid in configuration troubleshooting.
2025-10-14 19:12:44 +08:00
Max
168313c757 Update AcceptInvitation method to support optional user ID parameter
- Modified the AcceptInvitation method to accept an optional user ID parameter, allowing for updates to the user ID when accepting invitations without an existing user ID.
- Adjusted related tests to include the new user ID parameter, ensuring comprehensive coverage of invitation acceptance scenarios.
- Updated the team invitation acceptance logic to utilize the new parameter, enhancing the invitation flow and user management capabilities.
2025-10-14 14:15:41 +08:00
Max
721f47c345 Enhance invitation acceptance flow with invitation ID support
- Updated the AcceptInvitation method to require both invitation ID and token, improving the invitation acceptance process.
- Modified related tests to accommodate the new invitation ID parameter, ensuring comprehensive coverage of acceptance scenarios.
- Enhanced the invitation acceptance endpoint to validate invitation ID, providing clearer error handling for invalid or expired invitations.
- Refactored tests to include detailed scenarios for accepting invitations, including success and failure cases, ensuring robust testing of the invitation flow.
2025-10-14 11:58:20 +08:00
Max
0d83faeeca Add Yao user ID support in OIDC and token generation
- Enhanced the SignIDToken method to include the original Yao user ID in the token claims, improving user identification.
- Updated the MakeOIDCUserInfo function to extract and set the Yao user ID from the user map, ensuring consistency in user information.
- Modified the OIDCUserInfo structure to include a field for Yao user ID, facilitating better integration with Yao-specific features.
- Adjusted the team invitation response to include the inviter's user ID, enhancing the invitation context.
2025-10-14 09:56:29 +08:00
Max
5e67a9e5c0 Add Yao type information to user and token claims
- Enhanced the OIDCUserInfo structure to include YaoTypeID and YaoType fields for better user type management.
- Updated SignIDToken method to incorporate YaoTypeID and YaoType claims, ensuring comprehensive user type information in ID tokens.
- Modified team creation logic to set default type_id based on team configuration, improving team management capabilities.
- Refactored token generation methods to support additional type information in access and refresh tokens, enhancing overall token customization.
2025-10-13 18:26:52 +08:00
Max
a4c628f3c2 Add register configuration support for user management
- Introduced register configuration loading from the openapi/user/register directory, enhancing user management capabilities.
- Updated LoginThirdParty function to utilize locale-specific register configurations, improving localization support.
- Refactored RegisterConfig structure to include additional fields for better configuration management.
- Enhanced GetRegisterConfig function to provide fallback options for missing locale configurations, ensuring robustness in user registration processes.
2025-10-13 16:44:17 +08:00
Max
15f0750253 Enhance user type management with pricing and status fields
- Updated user type structure to include new fields for pricing: price_daily, price_monthly, price_yearly, and credits_monthly.
- Added status field to manage publishing states (draft, published, archived) for user types.
- Enhanced the user type API to support pricing operations, including retrieval and updates for pricing information.
- Refactored tests to cover new pricing functionalities and ensure robust handling of user type statuses.
2025-10-13 15:55:41 +08:00
Max
1af0a20015 Enhance user login functionality with detailed context tracking
- Updated the UpdateUserLastLogin method to accept a LoginContext, allowing for tracking of last login IP, user agent, device, and platform.
- Modified the LoginThirdParty and LoginByUserID functions to utilize the new LoginContext, improving the accuracy of login tracking.
- Enhanced the user model to include fields for last login details, ensuring comprehensive user activity logging.
- Refactored tests to validate the new login context handling, ensuring robust coverage of the updated functionality.
2025-10-13 09:58:16 +08:00
Max
d78ed77b9e Enhance token generation and storage to support optional extra claims
- Updated methods related to refresh token generation and storage to accept optional extra claims, allowing for additional metadata such as team_id and tenant_id.
- Refactored tests to utilize the new method signatures, ensuring comprehensive coverage of the updated functionality.
- Introduced a new endpoint for team selection that issues tokens with team-specific claims, improving user experience in multi-team scenarios.
2025-10-11 19:56:29 +08:00
Max
60c830099e Enhance login process to support team selection and improve token handling
- Added ScopeTeamSelection constant for temporary access token.
- Updated LoginByUserID function to include team selection logic based on user team count.
- Modified access token generation to use user subject for both MFA and team selection scenarios.
- Enhanced LoginResponse structure to include TokenType and Scope fields for clarity.
2025-10-11 18:23:09 +08:00
Max
afa5b2d3f2 Enhance team retrieval functionality and improve user team handling
- Updated GetTeamsByMember method to include role information and owner status for each team member.
- Refactored GinTeamList to utilize the new getUserTeams function, simplifying team retrieval logic and removing pagination.
- Introduced getUserTeams and getUserTeamsCount functions to encapsulate team membership logic, improving code organization and clarity.
- Removed deprecated team retrieval logic from user/team.go, streamlining the codebase.
2025-10-11 10:54:51 +08:00
Max
6abcf79dd7 Refactor MFA handling in login process
- Updated LoginResponse structure to replace MFAToken and MFATokenExpiresIn with AccessToken and ExpiresIn for improved clarity.
- Adjusted LoginByUserID and SendLoginCookies functions to utilize the new access token fields.
- Modified authback function to respond with the updated login response structure, enhancing the MFA flow.
2025-10-10 14:51:01 +08:00
Max
4a93b3580c Implement MFA token generation and update login response handling
- Removed the previous MFA check from the LoginThirdParty function and integrated MFA token generation within the LoginByUserID function.
- Enhanced the LoginResponse structure to include MFAToken and MFATokenExpiresIn fields for better MFA handling.
- Updated the SendLoginCookies function to manage MFA token cookies appropriately.
- Adjusted the authback function to respond with MFA status and token when MFA is required, improving the login flow for users with MFA enabled.
2025-10-10 14:25:18 +08:00
Max
5e5b633fba Add team retrieval and counting methods for user membership
- Introduced GetTeamsByMember and CountTeamsByMember methods in the DefaultUser struct to retrieve teams associated with a specific member and count the total number of teams, respectively.
- Updated the UserProvider interface to include these new methods.
- Enhanced the login response structure to include a status indicating whether team selection is required based on the user's team membership.
- Added error handling for team retrieval in the authentication process.
2025-10-10 11:57:47 +08:00
Max
4a94460377 Add MFA required error handling and update login response structure 2025-10-10 11:14:52 +08:00
Max
2569634ca2 Remove invitation management handlers and related business logic
- Deleted the invitation.go file, which contained handlers for team invitation management, including listing, creating, resending, and deleting invitations.
- Updated the user/member.go and user/team.go files to ensure consistent response handling by replacing direct JSON responses with a unified response method.
- Introduced a new PublicInvitationResponse type in user/types.go to facilitate public access to invitation details while excluding sensitive information.
- Refactored user/user.go to register new invitation-related process handlers for improved organization and clarity.
2025-10-10 08:42:05 +08:00
Max
03ecf96b51 Enhance messenger service with optional message type support for template sending
- Updated SendT, SendTWithProvider, SendTBatch, and SendTBatchMixed methods to accept an optional message type parameter, allowing for more flexible template usage.
- Refactored provider implementations for Mailgun, Twilio, and Mailer to accommodate the new message type parameter in their SendT and SendTBatch methods.
- Improved error handling for template retrieval and provider configuration, ensuring clearer feedback in case of issues.
- Added tests to validate the new functionality and ensure compatibility across different message types.
2025-10-09 12:11:54 +08:00