Skip to content

Conversation

KeeganBeuthin
Copy link

Enhanced Prompt Functionality - Match JS Utils SDK

Adds professional prompt functionality to PHP SDK that exactly matches JS Utils SDK behavior.

Changes

  • Added prompt constants: PROMPT_LOGIN, PROMPT_CREATE, PROMPT_NONE
  • Enhanced login(): auto-applies prompt=login
  • Enhanced register(): auto-applies prompt=create

Files Modified

  • lib/Sdk/Enums/AdditionalParameters.php - Added prompt constants
  • lib/KindeClientSDK.php - Enhanced login/register methods

Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

Walkthrough

Replaced hard-coded prompt strings with constants from AdditionalParameters. Updated login() and register() to default prompts via constants. register() now clears storage at start and continues PKCE flow. Added new prompt constants (login, create, none) to AdditionalParameters.

Changes

Cohort / File(s) Summary
Prompt constants in AdditionalParameters
lib/Sdk/Enums/AdditionalParameters.php
Added public constants: PROMPT_LOGIN='login', PROMPT_CREATE='create', PROMPT_NONE='none'; documented alignment with JS Utils SDK.
Login/Register prompt defaults and storage cleanup
lib/KindeClientSDK.php
Imported AdditionalParameters; login(): default prompt set to PROMPT_LOGIN for Authorization Code and PKCE; register(): removed forced grantType assignment, added cleanStorage() at start, default prompt set to PROMPT_CREATE, PKCE flow unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as Client App
  participant SDK as KindeClientSDK
  participant AS as Auth Server

  rect rgb(240,248,255)
  note over SDK: login()
  App->>SDK: login(options)
  alt prompt not provided
    SDK->>SDK: use AdditionalParameters::PROMPT_LOGIN
  else prompt provided
    SDK->>SDK: use provided prompt
  end
  SDK->>AS: Start Auth (AC or PKCE) with prompt
  AS-->>SDK: Redirect/Auth response
  SDK-->>App: Auth result
  end

  rect rgb(245,255,240)
  note over SDK: register()
  App->>SDK: register(options)
  SDK->>SDK: cleanStorage()
  alt prompt not provided
    SDK->>SDK: use AdditionalParameters::PROMPT_CREATE
  else prompt provided
    SDK->>SDK: use provided prompt
  end
  SDK->>AS: Start PKCE Auth with prompt
  AS-->>SDK: Redirect/Auth response
  SDK-->>App: Auth result
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ebbabd6 and d20918d.

📒 Files selected for processing (2)
  • lib/KindeClientSDK.php (3 hunks)
  • lib/Sdk/Enums/AdditionalParameters.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/KindeClientSDK.php (4)
lib/Sdk/Enums/AdditionalParameters.php (1)
  • AdditionalParameters (5-25)
lib/Sdk/OAuth2/AuthorizationCode.php (2)
  • AuthorizationCode (10-52)
  • authenticate (30-51)
lib/Sdk/OAuth2/PKCE.php (2)
  • authenticate (30-52)
  • PKCE (10-53)
test/Sdk/KindeClientSDK.php (1)
  • cleanStorage (495-498)
🔇 Additional comments (5)
lib/Sdk/Enums/AdditionalParameters.php (1)

7-11: LGTM! Well-documented prompt constants added.

The new prompt constants are well-defined with clear comments explaining their purpose. The values match the expected OAuth2 prompt parameter values and align with the JavaScript Utils SDK as mentioned in the PR objectives.

lib/KindeClientSDK.php (4)

12-12: LGTM! Import added for constants.

The import of AdditionalParameters is correctly added to support the use of prompt constants instead of hard-coded strings.


204-206: LGTM! Consistent use of prompt constant in authorization code flow.

The change from hard-coded 'login' string to AdditionalParameters::PROMPT_LOGIN constant improves maintainability and consistency across the codebase.


211-213: LGTM! Consistent use of prompt constant in PKCE flow.

The change from hard-coded 'login' string to AdditionalParameters::PROMPT_LOGIN constant maintains consistency with the authorization code flow and improves code maintainability.


234-238: LGTM! Enhanced register method with storage cleanup and consistent prompt usage.

The changes improve the register method by:

  1. Adding cleanStorage() call at the start to ensure clean state
  2. Using the AdditionalParameters::PROMPT_CREATE constant instead of hard-coded 'register' string

The storage cleanup ensures a fresh authentication state for registration, which is a good practice.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

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