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

Implement an API endpoint an admin can use to update a user's password #779

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

eecavanna
Copy link
Collaborator

@eecavanna eecavanna commented Nov 18, 2024

In this branch, @shreddd implemented an API endpoint that administrators can use to update the password of an existing user.

Details

(TODO)

Related issue(s)

Fixes #778

Related subsystem(s)

  • Runtime API (except the Minter)
  • Minter
  • Dagster
  • Project documentation (in the docs directory)
  • MongoDB migrations
  • Other

Testing

  • I tested these changes (explain below)
  • I did not test these changes

I tested these changes by implementing a test_update_user test function and ensuring that it passes.

Documentation

  • I have not checked for relevant documentation yet (e.g. in the docs directory)
  • I have updated all relevant documentation so it will remain accurate
  • Other (explain below)

This PR is being created by someone other than the branch author. I do not know the extent to which the branch author has considered documentation.

Maintainability

  • Every Python function I defined includes a docstring (test functions are exempt from this)
  • Every Python function parameter I introduced includes a type hint (e.g. study_id: str)
  • All "to do" or "fix me" Python comments I added begin with either # TODO or # FIXME
  • I used black to format all the Python files I created/modified
  • The PR title is in the imperative mood (e.g. "Do X") and not the declarative mood (e.g. "Does X" or "Did X")

This PR is being created by someone other than the branch author. I do not know which of the above things the branch author has done.

nmdc_runtime/api/endpoints/users.py Outdated Show resolved Hide resolved
nmdc_runtime/api/endpoints/users.py Outdated Show resolved Hide resolved
nmdc_runtime/api/endpoints/users.py Outdated Show resolved Hide resolved
tests/test_api/test_endpoints.py Outdated Show resolved Hide resolved
tests/test_api/test_endpoints.py Outdated Show resolved Hide resolved
tests/test_api/test_endpoints.py Show resolved Hide resolved
Comment on lines +197 to +207
base_url = os.getenv("API_HOST")

@retry(wait=wait_random_exponential(multiplier=1, max=60), stop=stop_after_attempt(3))
def get_token():
"""
Fetch an auth token from the Runtime API, retrying until successful.

Randomly wait up to 2^x * 1 seconds between each retry until the range reaches 60
seconds, then randomly up to 60 seconds afterwards

"""
Copy link
Collaborator Author

@eecavanna eecavanna Nov 27, 2024

Choose a reason for hiding this comment

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

I suggest omitting the retry-related info from the function's docstring and documenting it at the decoration level instead. In my mental model of the situation, the function, itself, doesn't "know" it has been decorated.

Suggested change
base_url = os.getenv("API_HOST")
@retry(wait=wait_random_exponential(multiplier=1, max=60), stop=stop_after_attempt(3))
def get_token():
"""
Fetch an auth token from the Runtime API, retrying until successful.
Randomly wait up to 2^x * 1 seconds between each retry until the range reaches 60
seconds, then randomly up to 60 seconds afterwards
"""
base_url = os.getenv("API_HOST")
# Try up to three times, waiting for up to 60 seconds between each attempt.
@retry(wait=wait_random_exponential(multiplier=1, max=60), stop=stop_after_attempt(3))
def get_token():
"""
Fetch an auth token from the Runtime API.
"""

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.

Implement password reset flow for API users
2 participants