-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for changing a password. (#19)
- Loading branch information
1 parent
1fcb8e1
commit 6b2662e
Showing
9 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import autograder.api.common | ||
import autograder.api.config | ||
|
||
API_ENDPOINT = 'users/password/change' | ||
API_PARAMS = [ | ||
autograder.api.config.PARAM_USER_EMAIL, | ||
autograder.api.config.PARAM_USER_PASS, | ||
autograder.api.config.PARAM_NEW_PASS, | ||
] | ||
|
||
DESCRIPTION = 'Change your password to the one provided.' | ||
|
||
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 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
The `autograder.cli.users.password` package contains tools to manage user passwords. | ||
""" | ||
|
||
import sys | ||
|
||
import autograder.util.cli | ||
|
||
def main(): | ||
autograder.util.cli.auto_list() | ||
return 0 | ||
|
||
if (__name__ == '__main__'): | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import sys | ||
|
||
import autograder.api.users.password.change | ||
|
||
def run(arguments): | ||
result = autograder.api.users.password.change.send(arguments, exit_on_error = True) | ||
|
||
if (result['duplicate']): | ||
print("Your new password must be different from your previous password.") | ||
return 0 | ||
|
||
if (result['success']): | ||
print("You have successfully changed your password.") | ||
return 0 | ||
|
||
return 1 | ||
|
||
def main(): | ||
return run(_get_parser().parse_args()) | ||
|
||
def _get_parser(): | ||
parser = autograder.api.users.password.change._get_parser() | ||
return parser | ||
|
||
if (__name__ == '__main__'): | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"endpoint": "users/pass/change", | ||
"module": "autograder.api.users.password.change", | ||
"arguments": { | ||
"new-pass": "admin" | ||
}, | ||
"output": { | ||
"success": true, | ||
"duplicate": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"endpoint": "users/pass/change", | ||
"module": "autograder.api.users.password.change", | ||
"arguments": { | ||
"user": "[email protected]", | ||
"pass": "student", | ||
"new-pass": "spooky" | ||
}, | ||
"output": { | ||
"success": true, | ||
"duplicate": false | ||
} | ||
} |