jscheffl commented on code in PR #37044:
URL: https://github.com/apache/airflow/pull/37044#discussion_r1468667674
##########
airflow/providers/fab/auth_manager/security_manager/override.py:
##########
@@ -470,7 +470,9 @@ def reset_password(self, userid, password):
user = self.get_user_by_id(userid)
user.password = generate_password_hash(password)
self.reset_user_sessions(user)
- self.update_user(user)
+ if self.update_user(user) is False:
Review Comment:
Besides the True/False comment above, why not directly returning the result,
if the result is `False` returning `False` is more than needed.
##########
airflow/providers/fab/auth_manager/cli_commands/user_command.py:
##########
@@ -106,6 +106,27 @@ def _find_user(args):
return user
+@cli_utils.action_cli
+@providers_configuration_loaded
+def user_reset_password(args):
+ """Reset user password user from DB."""
+ user = _find_user(args)
+ if args.use_random_password:
+ password = "".join(random.choices(string.printable, k=16))
+ elif args.password:
+ password = args.password
+ else:
+ password = getpass.getpass("Password:")
+ password_confirmation = getpass.getpass("Repeat for confirmation:")
+ if password != password_confirmation:
+ raise SystemExit("Passwords did not match")
Review Comment:
To prevent code duplication and redundancy, can you put these lines into a
utility function and use it in here and `users_create(args)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]