diff options
Diffstat (limited to 'plugins/auth_remote/init.php')
-rw-r--r-- | plugins/auth_remote/init.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/plugins/auth_remote/init.php b/plugins/auth_remote/init.php index 65f188b8f..2ec2c87b2 100644 --- a/plugins/auth_remote/init.php +++ b/plugins/auth_remote/init.php @@ -1,7 +1,6 @@ <?php class Auth_Remote extends Plugin implements IAuthModule { - private $link; private $host; private $base; @@ -13,9 +12,8 @@ class Auth_Remote extends Plugin implements IAuthModule { } function init($host) { - $this->link = $host->get_link(); $this->host = $host; - $this->base = new Auth_Base($this->link); + $this->base = new Auth_Base(); $host->add_hook($host::HOOK_AUTH_USER, $this); } @@ -24,7 +22,7 @@ class Auth_Remote extends Plugin implements IAuthModule { $cert_serial = db_escape_string(get_ssl_certificate_id()); if ($cert_serial) { - $result = db_query($this->link, "SELECT login FROM ttrss_user_prefs, ttrss_users + $result = db_query("SELECT login FROM ttrss_user_prefs, ttrss_users WHERE pref_name = 'SSL_CERT_SERIAL' AND value = '$cert_serial' AND owner_uid = ttrss_users.id"); @@ -40,11 +38,14 @@ class Auth_Remote extends Plugin implements IAuthModule { function authenticate($login, $password) { $try_login = db_escape_string($_SERVER["REMOTE_USER"]); + // php-cgi + if (!$try_login) $try_login = db_escape_string($_SERVER["REDIRECT_REMOTE_USER"]); + if (!$try_login) $try_login = $this->get_login_by_ssl_certificate(); # if (!$try_login) $try_login = "test_qqq"; if ($try_login) { - $user_id = $this->base->auto_create_user($try_login); + $user_id = $this->base->auto_create_user($try_login, $password); if ($user_id) { $_SESSION["fake_login"] = $try_login; @@ -58,14 +59,14 @@ class Auth_Remote extends Plugin implements IAuthModule { $fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN']; if ($fullname){ $fullname = db_escape_string($fullname); - db_query($this->link, "UPDATE ttrss_users SET full_name = '$fullname' WHERE id = " . + db_query("UPDATE ttrss_users SET full_name = '$fullname' WHERE id = " . $user_id); } // update user mail $email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL']; if ($email){ $email = db_escape_string($email); - db_query($this->link, "UPDATE ttrss_users SET email = '$email' WHERE id = " . + db_query("UPDATE ttrss_users SET email = '$email' WHERE id = " . $user_id); } } @@ -76,6 +77,11 @@ class Auth_Remote extends Plugin implements IAuthModule { return false; } + + function api_version() { + return 2; + } + } ?> |