tl-its-umich-edu / remote-office-hours-queue

Virtual queuing tool supporting Zoom video conferencing and/or in person meetings.
https://officehours.it.umich.edu/
Apache License 2.0
12 stars 28 forks source link

Added Method for Verifying User Phone Numbers through Twilio #474

Closed andcarls closed 7 months ago

andcarls commented 7 months ago

PR Summary

Resolves feature request in #391. Previous PR #406 utilized Twilio Lookup, but did not verify phone numbers or implement UI. PR includes functionality for users to enter a phone number, receive a text-based OTP, and verify/update their phone number. Options to resend code (with 30s buffer to prevent abuse), go back available.

Notes

Screenshots

  1. Enter phone number and click on "Obtain a one-time phone verification code" OTP_start
  2. Wait to receive the OTP localhost_8003_preferences_
  3. Entered a wrong OTP localhost_8003_preferences_ (1)
  4. Entered a correct OTP OTP_verification_success
andcarls commented 7 months ago

New commits should address above reviews. Curious on your thoughts on the button styles for requesting and verifying/submitting OTP. I chose a secondary, dark gray button for requesting OTP, and a primary, blue button (same as old save button) for submitting.

zqian commented 7 months ago

Thanks! @andcarls. I need to check the button design with @HemanginiShah and @jonespm, too

jonespm commented 7 months ago

I believe in this app variables can be passed up through the spa_globals variable which is set on the backend. I'd be fine if you set it like this or even hardcoded it and created a new issue to improve the config in the future if you couldn't get it working.

https://github.com/tl-its-umich-edu/remote-office-hours-queue/blob/master/src%2Fofficehours_ui%2Fcontext_processors.py

On Fri, Apr 12, 2024, 6:03 PM Andrew Carlson @.***> wrote:

@.**** commented on this pull request.

In src/assets/src/components/preferences.tsx https://github.com/tl-its-umich-edu/remote-office-hours-queue/pull/474#discussion_r1563265467 :

@@ -69,25 +78,90 @@ function PreferencesEditor(props: PreferencesEditorProps) { label="As a host, I want to be notified via SMS when someone joins my empty queue." /> );

  • const validateAndSubmit = (e: React.SyntheticEvent) => {
  • const oneTimePasswordTimer = () => {
  • let timer = process.env.REACT_APP_OTP_TIMER ? parseInt(process.env.REACT_APP_OTP_TIMER) : 30;

Hmm, it appears that the error thrown is that "process" doesn't exist. I did some digging, and found that it is a bit more of a complex process to pass environment variables to React using webpack, requiring modifying the webpack scripts (in package.json) and the likely use of external modules (see Dotenv https://www.npmjs.com/package/dotenv). I tried implementing some of the solutions I found online, but keep running into errors. Especially, for some odd reason, that webpack can't find the Dotenv module even after installation.

A simple solution would be to modify webpack.config.js to include:

plugins: [ ..., new webpack.DefinePlugin({ 'process.env': { REACT_APP_OTP_TIMER: JSON.stringify(30), } }) ]

Only changes a few lines and confirmed to work, but a bit less useful than a .env file.

I have never had to forward env variables to the frontend through webpack, and am running into weird errors locally. Any suggestions or does anyone have any insights on how to do this?

— Reply to this email directly, view it on GitHub https://github.com/tl-its-umich-edu/remote-office-hours-queue/pull/474#discussion_r1563265467, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAGWN6B2WI5ASJ6CLFNCMLY5BKZFAVCNFSM6AAAAABFZ5WPC6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSOJYGUYDMMRYHE . You are receiving this because you were mentioned.Message ID: <tl-its-umich-edu/remote-office-hours-queue/pull/474/review/1998506289@ github.com>

zqian commented 7 months ago

I agree. If you cannot get the spa_globals approach to work, then you can switch back to the hard coded value for this pull request. Thanks!

andcarls commented 7 months ago

Got it to work with the spa_globals approach. Added it to the Page props that are passed to all pages for consistency & maintainability. Let me know if you would rather it be passed down explicitly, but it may be a bit messier and harder to understand in future.

zqian commented 7 months ago

The spa_globals approach works. We will keep the approach for now.

andcarls commented 7 months ago

Digit-by-digit input added & updated PR screenshots. Autofocuses on first input box, moves focus forward/backward between boxes on input/deletion, and enter key submits OTP. Let me know your thoughts.

zqian commented 7 months ago

@andcarls: great work!

I just have one more comment: When user clicks on the edit link to enter new phone number, and click on the button to generate new OTP. The page refreshes but with the last used OTP numbers. Please reset the OTP number (to empty value) after (1) success verification; (2) failed verification; or (3) every time when user starts with a new phone number.

andcarls commented 7 months ago

Done: commit is above your comment; github glitched out in syncing

HemanginiShah commented 7 months ago

Nice job! I like the screenshots for opt-in for text message and one time verification.

andcarls commented 7 months ago

@zqian thanks! Not sure if this message is intended for me, but I don't have write access to the repo, so I can't merge.

zqian commented 7 months ago

@andcarls No Problem! I will do the merge!

HemanginiShah commented 7 months ago

Hello Andrew, I don't see any validation link when entered the phone. Please see the attached image from qa.remoteo Kindly help me, I would be happy to schedule a zoom call.

image

andcarls commented 7 months ago

Hi Hema,

From what I can see on the QA site, none of the recent code changes have been deployed to the QA deployment yet, including mine and #479. I'm unsure about the process for deploying to QA, maybe @zqian or @jonespm know/have access?

HemanginiShah commented 7 months ago

OK Thanks, I will talk to them during our meeting today at 2:30 pm.

*With Warm Regards,* https://www.name-coach.com/hemangini-shah

Hemangini Shah https://www.name-coach.com/hemangini-shah, PMP , BI Analyst Senior, ITS

She/Her/Hers

On Wed, Apr 24, 2024 at 2:24 PM Andrew Carlson @.***> wrote:

Hi Hema,

From what I can see on the QA site, none of the recent code changes have been deployed to the QA deployment yet, including mine and #479 https://github.com/tl-its-umich-edu/remote-office-hours-queue/pull/479. I'm unsure about the process for deploying to QA, maybe @zqian https://github.com/zqian or @jonespm https://github.com/jonespm know/have access?

— Reply to this email directly, view it on GitHub https://github.com/tl-its-umich-edu/remote-office-hours-queue/pull/474#issuecomment-2075566401, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFEK2QEBXCADBEONHL3JZXLY672EVAVCNFSM6AAAAABFZ5WPC6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZVGU3DMNBQGE . You are receiving this because you commented.Message ID: @.*** com>

jonespm commented 7 months ago

Yes this app isn't auto deployed. We built and deployed it and found a few issues with testing that we're going to create new issues for.

HemanginiShah commented 6 months ago

FYI - Ask Chatgpt to provide test cases for the telephone number validation. Response below: When creating test cases for telephone number validation, it's essential to cover a variety of scenarios to ensure the validation function works correctly in different situations. Here are some common test cases:

Valid Phone Numbers

  1. Standard Format:
    • Input: 123-456-7890
    • Expected Output: Valid
  2. Parentheses and Spaces:
    • Input: (123) 456-7890
    • Expected Output: Valid
  3. Dotted Format:
    • Input: 123.456.7890
    • Expected Output: Valid
  4. International Format with Plus Sign:
    • Input: +1-123-456-7890
    • Expected Output: Valid
  5. No Separators:
    • Input: 1234567890
    • Expected Output: Valid
  6. International Format without Plus Sign:
    • Input: 1-123-456-7890
    • Expected Output: Valid

Invalid Phone Numbers

  1. Too Few Digits:
    • Input: 123-456-789
    • Expected Output: Invalid
  2. Too Many Digits:
    • Input: 123-456-78901
    • Expected Output: Invalid
  3. Letters Included:
    • Input: 123-ABC-7890
    • Expected Output: Invalid
  4. Special Characters:
    • Input: 123-456-789@
    • Expected Output: Invalid
  5. Incorrect Parentheses Usage:
    • Input: 123) 456-7890
    • Expected Output: Invalid
  6. Missing Area Code:
    • Input: 456-7890
    • Expected Output: Invalid
  7. Spaces Only:
    • Input:
    • Expected Output: Invalid
  8. Empty String:
    • Input: ``
    • Expected Output: Invalid
  9. Mixed Separators:
    • Input: 123.456-7890
    • Expected Output: Invalid
  10. Leading or Trailing Spaces:
    • Input: 123-456-7890
    • Expected Output: Invalid (or Valid depending on how you handle leading/trailing spaces)
  11. International Format Without Country Code:
    • Input: -123-456-7890
    • Expected Output: Invalid

Edge Cases

  1. Only Plus Sign:
    • Input: +
    • Expected Output: Invalid
  2. Only Digits:
    • Input: 123456
    • Expected Output: Invalid (if fewer than the required 10 digits)
  3. Multiple Plus Signs:
    • Input: +1+123-456-7890
    • Expected Output: Invalid
  4. Consecutive Separators:
    • Input: 123--456-7890
    • Expected Output: Invalid
  5. Non-Standard International Format:
    • Input: +1234567890
    • Expected Output: Invalid (depending on the format accepted)

Notes for Implementation

By covering these test cases, you can ensure robust telephone number validation that can handle a wide range of inputs.