From 0f28f81f8911e432ae4bf50da7ed2c334618fd95 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 27 Dec 2012 15:14:44 +0400 Subject: move authentication modules to plugins/ --- classes/pref/prefs.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index e8926194e..0922e43a8 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -28,8 +28,8 @@ class Pref_Prefs extends Handler_Protected { return; } - $module_class = "auth_" . $_SESSION["auth_module"]; - $authenticator = new $module_class($this->link); + global $pluginhost; + $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]); if (method_exists($authenticator, "change_password")) { print $authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw); @@ -188,9 +188,11 @@ class Pref_Prefs extends Handler_Protected { print ""; - if ($_SESSION["auth_module"]) { - $module_class = "auth_" . $_SESSION["auth_module"]; - $authenticator = new $module_class($this->link); + if ($_SESSION["auth_module"]) { + global $pluginhost; + + $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]); + } else { $authenticator = false; } @@ -258,7 +260,7 @@ class Pref_Prefs extends Handler_Protected { print ""; - if ($_SESSION["auth_module"] == "internal") { + if ($_SESSION["auth_module"] == "auth_internal") { print "

" . __("One time passwords / Authenticator") . "

"; @@ -802,11 +804,11 @@ class Pref_Prefs extends Handler_Protected { function otpenable() { $password = db_escape_string($_REQUEST["password"]); - - $module_class = "auth_" . $_SESSION["auth_module"]; - $authenticator = new $module_class($this->link); $enable_otp = $_REQUEST["enable_otp"] == "on"; + global $pluginhost; + $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]); + if ($authenticator->check_password($_SESSION["uid"], $password)) { if ($enable_otp) { @@ -824,8 +826,8 @@ class Pref_Prefs extends Handler_Protected { function otpdisable() { $password = db_escape_string($_REQUEST["password"]); - $module_class = "auth_" . $_SESSION["auth_module"]; - $authenticator = new $module_class($this->link); + global $pluginhost; + $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]); if ($authenticator->check_password($_SESSION["uid"], $password)) { -- cgit v1.2.3