Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for google sign in issue #1741

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GMayank0310
Copy link
Contributor

@GMayank0310 GMayank0310 commented Jan 17, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced account deletion process to remove associated email confirmation records.
    • Improved user account management functionality.
  • Bug Fixes

    • Ensured complete cleanup of user-related data during account deletion.
  • Tests

    • Added test cases to validate email confirmation record management during account operations.

Copy link

coderabbitai bot commented Jan 17, 2025

Walkthrough

The changes enhance the account deletion process by ensuring that email confirmation records are also deleted when a user account is removed. This involves modifications to the AccountProcessor class to include the deletion of the email confirmation record, as well as updates to test files to validate this new functionality. The updates span across the account processor, data objects, and integration tests, ensuring a comprehensive approach to account management.

Changes

File Change Summary
kairon/shared/account/processor.py Added line to delete email confirmation record during account deletion. Method signature updated to include email parameter.
tests/integration_test/services_test.py Imported UserEmailConfirmation and added record creation in password reset test. Added assertion to check UserEmailConfirmation count post-deletion.
tests/unit_test/api/api_processor_test.py Imported UserEmailConfirmation, updated tests to include handling of email confirmations during account setup and deletion. New assertions added for validation.

Sequence Diagram

sequenceDiagram
    participant User
    participant AccountProcessor
    participant Database
    
    User->>AccountProcessor: Request Account Deletion
    AccountProcessor->>Database: Delete User Account
    AccountProcessor->>Database: Delete Email Confirmation Record
    Database-->>AccountProcessor: Deletion Confirmed
    AccountProcessor-->>User: Account Deleted
Loading

Poem

🐰 A Rabbit's Ode to Clean Accounts 🔍

With emails wiped and records clear,
No trace remains, have no fear!
Delete the user, delete their sign,
Our database now looks so fine!
Cleanup complete, no data to trace! 🧹


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a77482 and 7f09309.

📒 Files selected for processing (1)
  • tests/integration_test/services_test.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integration_test/services_test.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Python CI

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 238c76d and 9a77482.

📒 Files selected for processing (3)
  • kairon/shared/account/processor.py (1 hunks)
  • tests/integration_test/services_test.py (2 hunks)
  • tests/unit_test/api/api_processor_test.py (9 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (python)
  • GitHub Check: Python CI
🔇 Additional comments (13)
tests/integration_test/services_test.py (2)

31-31: LGTM!

The import of UserEmailConfirmation is properly placed and aligns with the account deletion enhancement.


29534-29534: Verify PR scope and completeness.

The PR title mentions fixing a Google sign-in issue, but the changes appear to focus on account deletion functionality. Could you please clarify:

  1. How do these changes address the Google sign-in issue?
  2. Are there additional changes needed to fully resolve the sign-in problem?
kairon/shared/account/processor.py (1)

1272-1272: LGTM! Good cleanup of email confirmation records.

The addition of email confirmation record deletion during account deletion ensures proper cleanup of all associated user data.

tests/unit_test/api/api_processor_test.py (10)

482-483: LGTM! Good test setup.

Properly setting up email confirmation record before account setup to ensure complete test coverage.


494-494: LGTM! Good verification of cleanup.

Comprehensive verification that email confirmation record is properly deleted during account deletion.

Also applies to: 499-500


515-517: LGTM! Good test setup for shared bot scenario.

Properly setting up email confirmation record before shared bot test to ensure complete test coverage.


529-529: LGTM! Good verification of cleanup for shared bot.

Comprehensive verification that email confirmation record is properly deleted during shared bot deletion.

Also applies to: 533-534


544-545: LGTM! Good test setup for account deletion.

Properly setting up email confirmation record before account deletion test to ensure complete test coverage.


552-552: LGTM! Good verification of cleanup for account deletion.

Comprehensive verification that email confirmation record is properly deleted during account deletion.

Also applies to: 557-560


570-571: LGTM! Good test setup for user deletion.

Properly setting up email confirmation record before user deletion test to ensure complete test coverage.


591-591: LGTM! Good verification of cleanup for user deletion.

Comprehensive verification that email confirmation record is properly deleted during user deletion.

Also applies to: 596-598


607-608: LGTM! Good test setup for account re-add scenario.

Properly setting up email confirmation record before account deletion and re-add test to ensure complete test coverage.


614-614: LGTM! Good verification of cleanup for account re-add.

Comprehensive verification that email confirmation record is properly deleted during account deletion and re-add.

Also applies to: 621-622

@@ -29530,7 +29531,7 @@ def _password_reset(*args, **kwargs):
"Authorization": pytest.token_type_delete + " " + pytest.access_token_delete
},
).json()

UserEmailConfirmation(email="integration@demo.ai").save()
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Test logic needs revision for proper coverage.

The current implementation has several issues:

  1. The email confirmation record is created after the account deletion operation
  2. There's no verification that the email confirmation record is properly deleted
  3. The email address is hardcoded

Consider this revised approach:

+    # Create email confirmation record before deletion
+    test_email = "integration@demo.ai"
+    UserEmailConfirmation(email=test_email).save()
+    
+    # Verify record exists
+    assert UserEmailConfirmation.objects(email=test_email).count() == 1
+
     response = client.delete(
         f"/api/account/delete/{pytest.email_delete}",
         headers={
             "Authorization": pytest.token_type_delete + " " + pytest.access_token_delete
         },
     ).json()
-    UserEmailConfirmation(email="integration@demo.ai").save()
     assert response["success"]
     assert response["message"] == "Account deleted"
     assert response["error_code"] == 0
+    
+    # Verify email confirmation record is deleted
+    assert UserEmailConfirmation.objects(email=test_email).count() == 0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
UserEmailConfirmation(email="integration@demo.ai").save()
# Create email confirmation record before deletion
test_email = "integration@demo.ai"
UserEmailConfirmation(email=test_email).save()
# Verify record exists
assert UserEmailConfirmation.objects(email=test_email).count() == 1
response = client.delete(
f"/api/account/delete/{pytest.email_delete}",
headers={
"Authorization": pytest.token_type_delete + " " + pytest.access_token_delete
},
).json()
assert response["success"]
assert response["message"] == "Account deleted"
assert response["error_code"] == 0
# Verify email confirmation record is deleted
assert UserEmailConfirmation.objects(email=test_email).count() == 0

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