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

Added support for the password/reset API endpoint. #20

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions autograder/api/users/password/reset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import autograder.api.common
import autograder.api.config

API_ENDPOINT = 'users/password/reset'
API_PARAMS = [
autograder.api.config.PARAM_USER_EMAIL,
]

DESCRIPTION = 'Reset to a random password that will be emailed to you.'

def send(arguments, **kwargs):
return autograder.api.common.handle_api_request(arguments, API_PARAMS, API_ENDPOINT, **kwargs)

def _get_parser():
parser = autograder.api.config.get_argument_parser(
description = DESCRIPTION,
params = API_PARAMS)

return parser
19 changes: 19 additions & 0 deletions autograder/cli/users/password/reset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys

import autograder.api.users.password.reset

def run(arguments):
autograder.api.users.password.reset.send(arguments, exit_on_error = True)
print("The server has successfully processed your request.")
print("Check your email for the new password.")
return 0

def main():
return run(_get_parser().parse_args())

def _get_parser():
parser = autograder.api.users.password.reset._get_parser()
return parser

if (__name__ == '__main__'):
sys.exit(main())
7 changes: 7 additions & 0 deletions tests/api/data/test_password_reset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"module": "autograder.api.users.password.reset",
"arguments": {
"user": "[email protected]"
},
"output": {}
}