Skip to content
Snippets Groups Projects
Verified Commit f5c1dace authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'dev' into f-entity-role

parents 9599b065 d971805b
Branches
Tags
2 merge requests!33MAINT: change arguments of create_user,!15F entity role
Pipeline #13615 passed with warnings
......@@ -25,6 +25,7 @@ guidelines](https://gitlab.com/caosdb/caosdb/-/blob/dev/REVIEW_GUIDELINES.md)
- [ ] All automated tests pass
- [ ] Reference related Issues
- [ ] Up-to-date CHANGELOG.md
- [ ] Add type hints in created/changed code
- [ ] Annotations in code (Gitlab comments)
- Intent of new code
- Problems with old code
......
......@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ###
- It is possible now to supply a password for caosdb_admin on the command line and also activate the user directly using "-c".
### Deprecated ###
* `id_query(ids)` in apiutils
......
......@@ -51,6 +51,7 @@ def configure(inifile):
def get_config():
global _pycaosdbconf
return _pycaosdbconf
......
......@@ -116,13 +116,16 @@ def _promt_for_pw():
def do_create_user(args):
password = None
password = args.user_password
if args.ask_password is True:
password = _promt_for_pw()
try:
admin._insert_user(name=args.user_name,
email=args.user_email, password=password)
if args.activate_user:
do_activate_user(args)
except HTTPClientError as e:
print(e.msg)
......@@ -136,7 +139,10 @@ def do_deactivate_user(args):
def do_set_user_password(args):
if args.user_password is None:
password = _promt_for_pw()
else:
password = args.user_password
admin._update_user(name=args.user_name, password=password)
......@@ -301,10 +307,21 @@ USAGE
# users (CRUD)
subparser = subparsers.add_parser(
"create_user",
help="Create a new user in caosdb's internal user database.")
help="Create a new user in caosdb's internal user database. You need "
" to activate the user before use.")
subparser.set_defaults(call=do_create_user)
subparser.add_argument("-a", "--ask-password",
mg = subparser.add_mutually_exclusive_group()
mg.add_argument("-a", "--ask-password",
help="Prompt for a password.", action="store_true")
mg.add_argument(
"--password",
dest="user_password",
default=None,
help="Alternative way to provide the new user's password. Please "
"consider to use the more secure, interactive way (-a option).")
subparser.add_argument("-c", "--activate-user",
help="Activate the user after creation.",
action="store_true")
subparser.add_argument(
metavar='USERNAME',
dest="user_name",
......@@ -331,12 +348,20 @@ USAGE
subparser = subparsers.add_parser(
"set_user_password",
help="Set a new password for a user. The password is not to be given on the command line for security reasons. You will be prompted for the password.")
help="Set a new password for a user. "
"By default, you will be prompted for the password.")
subparser.set_defaults(call=do_set_user_password)
subparser.add_argument(
metavar='USERNAME',
dest="user_name",
help="The name of the user who's password is to be set.")
subparser.add_argument(
metavar='PASSWORD',
nargs="?",
dest="user_password",
default=None,
help="Alternative way to provide the user's new password. "
"The more secure (and default way) is to provide it interactively.")
subparser = subparsers.add_parser(
"set_user_entity",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment