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

Apply WebOTP pattern to short messages in Boilerplate (#9612) #9613

Conversation

ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Jan 3, 2025

closed #9612

Summary by CodeRabbit

  • New Features

    • Enhanced SMS message formatting across multiple identity-related methods
    • Improved token communication by including web application URL in SMS messages
  • Bug Fixes

    • Standardized SMS message construction for better user clarity and context

@ysmoradi ysmoradi requested a review from msynk January 3, 2025 15:32
Copy link

coderabbitai bot commented Jan 3, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request focuses on enhancing SMS message formatting across multiple identity-related controllers in the Boilerplate project. The changes involve modifying SMS message construction in various methods like SendConfirmPhoneToken, SendResetPasswordToken, SendOtp, SendTwoFactorToken, SendChangePhoneNumberToken, and SendElevatedAccessToken. The primary modification is to include the web application URL and token in a more structured format, improving the clarity and context of SMS notifications for users.

Changes

File Change Summary
...Identity/IdentityController.PhoneConfirmation.cs Updated SMS message construction to include web app URL and token
...Identity/IdentityController.ResetPassword.cs Modified SMS message format to enhance token communication
...Identity/IdentityController.cs Refined SMS message generation in SendOtp and SendTwoFactorToken methods
...Identity/UserController.cs Enhanced SMS message formatting in SendChangePhoneNumberToken and SendElevatedAccessToken methods

Sequence Diagram

sequenceDiagram
    participant User
    participant Controller
    participant PhoneService
    participant Localizer

    User->>Controller: Request SMS Token
    Controller->>Localizer: Get Localized Message
    Localizer-->>Controller: Localized Text
    Controller->>Controller: Generate Token
    Controller->>Controller: Construct Enhanced SMS Message
    Controller->>PhoneService: Send SMS with URL and Token
    PhoneService->>User: Deliver SMS
Loading

Assessment against linked issues

Objective Addressed Explanation
Make SMS messages Web OTP compatible [#9612]

Poem

🐰 A rabbit's tale of tokens bright,
SMS messages now shine with might!
Web URLs dancing with each line,
OTP tokens now perfectly align,
Hopping through code with digital delight! 📱✨


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.

@ysmoradi ysmoradi marked this pull request as ready for review January 4, 2025 01:25
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: 0

🧹 Nitpick comments (6)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/IdentityController.PhoneConfirmation.cs (1)

81-82: Leverage consistent placeholders or formatting for Web OTP.
Right now, the message uses the host name and an inline #token marker. While functional, consider applying a consistent string format across all methods (e.g., @hostname #token) or adjusting placeholders to avoid potential confusion, especially if extra lines/spaces might affect older devices or carriers.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/IdentityController.ResetPassword.cs (1)

52-53: Consider adding a user-friendly message or state for the token.
Appending the token explicitly might risk confusion or unintended user sharing. Some prefer tokens to be partially masked for security. Weigh the pros/cons of exposing it in plain text.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/UserController.cs (3)

231-234: Proceed with consistency in localization placeholders.
Here, the localized string is appended with the host name using a newline. For brand identity or clarity, consider adding more context, such as “Use this code on ” to ensure that the message is self-explanatory to recipients.


403-404: Maintain the same comment style for Web OTP.
The /* Web OTP */ comment is consistent across the code but ensure every usage references the same pattern or clarifies how to use the token. Documenting potential steps after receiving an OTP (e.g., “Paste the code on the site”) might help end users.


417-417: Expand or refine push message content.
Push notifications are often displayed out of context. Consider including an app name or a short heading (e.g., “[AppName] Elevated Access Code”) to help users identify messages quickly in their notification trays.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/IdentityController.cs (1)

373-374: Ensure uniform user experience across all 2FA methods.
Here, a common pattern is used with @{host} #{token} for Web OTP. Ensure it is consistent with other 2FA channels (like authenticator apps or push confirmations) so users don’t see conflicting instructions.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between efbf29f and 7578e90.

📒 Files selected for processing (4)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/IdentityController.PhoneConfirmation.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/IdentityController.ResetPassword.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/IdentityController.cs (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/UserController.cs (4 hunks)
🔇 Additional comments (4)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/IdentityController.PhoneConfirmation.cs (1)

83-83: Ensure error handling or logging for phoneService.SendSms.
If SendSms fails due to external issues (e.g., invalid phone numbers or provider downtime), it might raise an exception. Confirm that there is appropriate error handling or logs to help diagnose SMS delivery problems.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/UserController.cs (2)

394-394: Check whether the token might need partial masking for security.
The ElevatedAccessToken is sensitive; consider reinforcing or clarifying whether the entire token is safe to display or if only partial exposure is needed to mitigate social engineering risks.


413-413: Confirm that the client(s) side gracefully handles this “SHOW_MESSAGE” event.
The server emits the event to all user sessions. Confirm front-end logic for presenting or dismissing the message to prevent confusion if multiple sessions are active.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/IdentityController.cs (1)

311-313: Validate usage of the newly generated token.
Please confirm that the generated token for SMS OTP and the magicLinkToken for email usage are not conflicting or overwriting each other. Adequate naming, logs, or separate fields can avoid confusion in multi-step flows.

@msynk msynk changed the title Apply Web OTP pattern to Boilerplate short sent messages (#9612) Apply Web OTP pattern to short messages in Boilerplate (#9612) Jan 4, 2025
@msynk msynk changed the title Apply Web OTP pattern to short messages in Boilerplate (#9612) Apply WebOTP pattern to short messages in Boilerplate (#9612) Jan 4, 2025
@msynk msynk merged commit 4a4f795 into bitfoundation:develop Jan 4, 2025
3 checks passed
@ysmoradi ysmoradi deleted the 9612-boilerplate-project-template-sms-messages-are-not-web-otp-compatible branch January 4, 2025 11:39
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.

Boilerplate project template sms messages are not web otp compatible
2 participants