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

feat(api): Add endpoint to allow user to resend confirmation email #543

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

paulespinosa
Copy link
Member

A new API endpoint has been added to allow a user to resend a registration confirmation to a user with the provided email.

Limitations:
For the MVP, this commit causes the API to rely on the Cognito service to rate limit the requests rather than keep track of the requests itself.

closes #542

A new API endpoint has been added to allow a user to resend a registration
confirmation to a user with the provided email.

Limitations:
For the MVP, this commit causes the API to rely on the Cognito service to rate
limit the requests rather than keep track of the requests itself.

closes #542
except botocore.exceptions.ClientError as error:
match error.response['Error']['Code']:
case 'UserNotFoundException':
msg = "User not found. Confirmation not sent."
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really like the more specific breakdown of possible errors. Might be worth doing this with the other routes

@erikguntner
Copy link
Collaborator

@paulespinosa One thing to note, I checked out the branch to test the endpoint and I ran into an error with the match statements. Apparently, this feature is in versions Python 3.10+, so we might want to change the required version in the docs since it's currently at 3.5.2+

@paulespinosa
Copy link
Member Author

paulespinosa commented Jul 20, 2023 via email

@paulespinosa
Copy link
Member Author

paulespinosa commented Jul 20, 2023 via email

/auth/signin:
$ref: "./paths/auth/authSignin.yaml"
/auth/resend_confirmation_code:
Copy link
Member

Choose a reason for hiding this comment

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

is this suppose to be snake or camel case

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @ju1es! Thank you for taking a look. This is a good and important question.

Regarding API endpoint (OpenAPI paths):

I checked again. I see there are both ways being used in this file (e.g. /serviceProviders, /auth/initialInvite, and /auth/forgot_password, /auth/forgot_password/confirm).

  • When I searched for guidance in the OpenAPI documentation, I didn't see any explicit convention written, but I did see they used camelCase (this is called mixed case in Python PEP8) in their examples.
  • I then checked https://restfulapi.net/resource-naming/ which only says to be consistent in whatever convention is used and provides "hints" to use hyphen (-) to separate words, avoid underscores, and use lowercase letters.
  • Then, I checked the connexion documentation and saw they had an example using snake case (/hello_world) (doh!).
  • Finally, I tried searching for preferences from the React side but couldn't find anything.

Do you, @erikguntner, @Joshua-Douglas know if there is a preference on the front end side regarding the API endpoint naming convention?

Regarding OpenAPI operationId:

I tend to use snake case to follow PEP8 function and variable name convention because it's implemented in Python and the auth_controller.py is dominantly snake case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@paulespinosa Yeah I was using snake case since that's what I saw in the Flask and connexion docs, but I defer to you all with more Python experience for what you wanna do moving forward. Camel case is the standard in Javascript land and always appreciated when getting data back from a db, but the endpoints don't necessarily need to be written in it. Hyphens look fairly clean tho

Copy link
Member

@ju1es ju1es Jul 26, 2023

Choose a reason for hiding this comment

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

so many options! thanks for looking into it so thoroughly @paulespinosa

+1 hyphens for me as well. i don't have a strong preference except that we adhere to one convention for consistency.

@ju1es
Copy link
Member

ju1es commented Jul 25, 2023

preemptively approving but any tests for the controller?

@paulespinosa
Copy link
Member Author

preemptively approving but any tests for the controller?

I was thinking about this too. Right now, this is a wrapper around the boto3 client, and I was hesitant to mock it. I haven't read all of boto3 documentation yet. So, I'd like some help to write the tests.

@ju1es
Copy link
Member

ju1es commented Jul 26, 2023

preemptively approving but any tests for the controller?

I was thinking about this too. Right now, this is a wrapper around the boto3 client, and I was hesitant to mock it. I haven't read all of boto3 documentation yet. So, I'd like some help to write the tests.

yeah I wasn't sure how to test the controllers which is why I pulled some of the logic out into the 'repositories' class. I think unit tests would be nice. thinking a little more about it, I'm leaning as long as it's been manually tested we can roll with it for now just so we can get things up and running.

@erikguntner erikguntner merged commit 5268b4b into main Jul 31, 2023
1 check passed
@Joshua-Douglas Joshua-Douglas deleted the 542-resend-confirm-email branch December 12, 2023 23:05
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.

Resend confirmation email
3 participants