Skip to content

Provide basic group functionality for customer segmentation#27

Open
JustShah wants to merge 4 commits into
add-user-groupsfrom
25-add-users-automatically-to-groups-when-created-via-api
Open

Provide basic group functionality for customer segmentation#27
JustShah wants to merge 4 commits into
add-user-groupsfrom
25-add-users-automatically-to-groups-when-created-via-api

Conversation

@JustShah

Copy link
Copy Markdown

Overview:

This pull request introduces functionality to automatically assign a user group to new users upon signup, based on the store's configuration. This enhancement allows for better user management and organization within the application by ensuring that users are categorized into appropriate groups from the moment they register.

Key Changes:

  1. User Group Assignment Logic:

    • Implemented the set_user_group method in the Spree::Api::UsersController. This method checks if the current store has the enforce_group_upon_signup setting enabled and assigns the default user group to new users accordingly.
  2. API Configuration Update:

    • Updated the user_attributes preference in Spree::ApiConfiguration to include :user_group_id. This change allows the user group information to be included in API responses for user details.
  3. Request Specs for User Group Assignment:

    • Added tests to the user request specs to verify the correct assignment of the default user group upon user creation. Scenarios were included to ensure that the user group is assigned when enforce_group_upon_signup is enabled and not assigned when it is disabled.
  4. Permitted Attributes Update:

    • Updated the @@user_attributes in Spree::PermittedAttributes to include :user_group_id, allowing the user group to be permitted during user creation and updates via the API.

Benefits:

  • Enhances user management by ensuring new users are automatically categorized into the appropriate user group.
  • Provides a more robust API response by including user group information.

@JustShah JustShah force-pushed the 25-add-users-automatically-to-groups-when-created-via-api branch from e5868ec to b19d82d Compare April 10, 2025 13:25
@fthobe fthobe changed the title Add Users Automatically To Groups When Created Via Api Provide basic group functionality for customer segmentation Apr 10, 2025
@JustShah JustShah force-pushed the 25-add-users-automatically-to-groups-when-created-via-api branch from b19d82d to d6bea81 Compare April 10, 2025 14:37
- Implemented the `set_user_group` method in `Spree::Api::UsersController`.
- This method assigns the default user group to a new user if the current store has the `enforce_group_upon_signup` setting enabled.
- Ensures that new users are automatically added to the specified user group during signup.
- Modified the `user_attributes` preference in `Spree::ApiConfiguration` to include `:user_group_id`.
- This change allows the user group information to be included in API responses for user details.
- Updated the user request specs to test the assignment of the default user group upon user creation.
- Added scenarios to verify that the user group is assigned when `enforce_group_upon_signup` is enabled and not assigned when it is disabled.
- Updated the `@@user_attributes` in `Spree::PermittedAttributes` to include `:user_group_id`.
- This allows the user group to be permitted during user creation and updates via the API.
@JustShah JustShah force-pushed the 25-add-users-automatically-to-groups-when-created-via-api branch from d6bea81 to 2873fb4 Compare April 11, 2025 05:06
@JustShah JustShah linked an issue Apr 11, 2025 that may be closed by this pull request
@JustShah JustShah closed this Apr 11, 2025
@JustShah JustShah reopened this Apr 11, 2025
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.

Add users automatically to groups when created via API

1 participant