Skip to content

Conversation

evansharp
Copy link

@evansharp evansharp commented Oct 15, 2025

This PR improves OAuth integration with the Shield add-on by causing the Oauth controller to fire the register event in the same way that Shield does when a manual registration occurs.

Since this seems like an expected behaviour, I have not added any documentation for it.

Summary by CodeRabbit

  • New Features
    • OAuth sign-ups now follow the same post-registration flows as standard sign-ups, ensuring consistent behavior after account creation.
    • Users registering via OAuth can receive the same follow-up actions such as welcome messages, confirmations, or security checks where configured.
    • Improves compatibility with existing registration workflows so downstream processes (notifications, logs, audits) apply uniformly to OAuth accounts.

Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

Adds an event trigger to the OAuth registration flow: imports CodeIgniter\Events\Events and triggers a 'register' event after creating a user and assigning them to the default group.

Changes

Cohort / File(s) Summary
OAuth registration event integration
src/Controllers/OAuthController.php
Import CodeIgniter\Events\Events; after user creation and default group assignment, call Events::trigger('register', $user) to emit a registration event.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User as OAuth User
  participant OP as OAuth Provider
  participant C as OAuthController
  participant UM as UserModel
  participant GM as GroupModel
  participant E as Events
  participant L as Shield Listener(s)

  User->>OP: Authenticate via OAuth
  OP-->>C: OAuth callback with user data
  C->>UM: Create & save user
  UM-->>C: User saved
  C->>GM: Add user to default group
  GM-->>C: Group assigned
  rect rgba(220,255,220,0.3)
    note right of C: New integration
    C->>E: trigger('register', user)
    E-->>L: Notify registered listeners
  end
  C-->>User: Proceed to post-login flow
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hopped through code with tidy cheer,
A trigger blooms—new signals here.
OAuth whispers, “User’s in!”
Events now ripple, soft and thin.
Ears up high, I thump the ground—
Shield hears the call, a gentle sound.
Carrots merged; the change is sound. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly captures the main change of adding Shield’s registration event trigger into the OAuth flow by invoking Events::trigger on registration. It directly reflects the code modification in OAuthController.php and aligns with the PR’s objective to mirror Shield’s manual registration behavior. It names both the source (Shield) and the target (OAuth), making the purpose immediately understandable.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 82f07b6 and 511ea08.

📒 Files selected for processing (1)
  • src/Controllers/OAuthController.php (2 hunks)
🔇 Additional comments (2)
src/Controllers/OAuthController.php (2)

17-17: LGTM!

The import is correctly added and follows the existing import structure.


113-115: Verify Shield’s register event timing and add test coverage

  • Confirm in Shield’s registration flow the register event fires after the user is added to the default group.
  • Add tests to ensure Events::trigger('register', $user) fires for OAuth registrations.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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