add a separate interface for auth modules w/ change_password() method

This commit is contained in:
Andrew Dolgov 2023-10-27 22:21:30 +03:00
parent 925256c81f
commit a1a2fe40f6
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
3 changed files with 8 additions and 5 deletions

4
classes/IAuthModule2.php Normal file
View File

@ -0,0 +1,4 @@
<?php
interface IAuthModule2 extends IAuthModule {
function change_password(int $owner_uid, string $old_password, string $new_password) : string;
}

View File

@ -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>

View File

@ -1,5 +1,5 @@
<?php
class Auth_Internal extends Auth_Base {
class Auth_Internal extends Auth_Base implements IAuthModule2 {
function about() {
return array(null,