From a1a2fe40f631737e9d7eeb79a5cc9a8d1ab124bc Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 27 Oct 2023 22:21:30 +0300 Subject: [PATCH] add a separate interface for auth modules w/ change_password() method --- classes/IAuthModule2.php | 4 ++++ classes/Pref_Prefs.php | 7 +++---- plugins/auth_internal/init.php | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 classes/IAuthModule2.php diff --git a/classes/IAuthModule2.php b/classes/IAuthModule2.php new file mode 100644 index 000000000..093ea7e93 --- /dev/null +++ b/classes/IAuthModule2.php @@ -0,0 +1,4 @@ +get_plugin($_SESSION["auth_module"]); - if (method_exists($authenticator, "change_password")) { + if (implements_interface($authenticator, "IAuthModule2")) { + /** @var IAuthModule2 $authenticator */ print format_notice($authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw)); } else { print "ERROR: ".format_error("Function not supported by authentication module."); @@ -325,9 +326,7 @@ class Pref_Prefs extends Handler_Protected { $authenticator = false; } - $otp_enabled = UserHelper::is_otp_enabled($_SESSION["uid"]); - - if ($authenticator && method_exists($authenticator, "change_password")) { + if ($authenticator && implements_interface($authenticator, "IAuthModule2")) { ?> diff --git a/plugins/auth_internal/init.php b/plugins/auth_internal/init.php index 697d0d0d2..881d867cf 100644 --- a/plugins/auth_internal/init.php +++ b/plugins/auth_internal/init.php @@ -1,5 +1,5 @@