summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-10-27 22:21:30 +0300
committerAndrew Dolgov <[email protected]>2023-10-27 22:29:03 +0300
commita1a2fe40f631737e9d7eeb79a5cc9a8d1ab124bc (patch)
tree9beeb6a30a9c5b0ed3b4fbe4681e35f324c89216
parent925256c81f3be3678ced527fe32f5ae59418ad00 (diff)
add a separate interface for auth modules w/ change_password() method
-rw-r--r--classes/IAuthModule2.php4
-rw-r--r--classes/Pref_Prefs.php7
-rw-r--r--plugins/auth_internal/init.php2
3 files changed, 8 insertions, 5 deletions
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 @@
+<?php
+interface IAuthModule2 extends IAuthModule {
+ function change_password(int $owner_uid, string $old_password, string $new_password) : string;
+}
diff --git a/classes/Pref_Prefs.php b/classes/Pref_Prefs.php
index 5aa2382dd..c9eb89631 100644
--- a/classes/Pref_Prefs.php
+++ b/classes/Pref_Prefs.php
@@ -174,7 +174,8 @@ class Pref_Prefs extends Handler_Protected {
$authenticator = PluginHost::getInstance()->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")) {
?>
<div style='display : none' id='pwd_change_infobox'></div>
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 @@
<?php
-class Auth_Internal extends Auth_Base {
+class Auth_Internal extends Auth_Base implements IAuthModule2 {
function about() {
return array(null,