2012-08-16 11:30:35 +00:00
|
|
|
<?php
|
|
|
|
class Auth_Base {
|
2012-09-04 08:46:08 +00:00
|
|
|
function check_password($owner_uid, $password) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-16 11:30:35 +00:00
|
|
|
function authenticate($login, $password) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Auto-creates specified user if allowed by system configuration
|
|
|
|
// Can be used instead of find_user_by_login() by external auth modules
|
|
|
|
function auto_create_user($login) {
|
|
|
|
if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) {
|
|
|
|
$user_id = $this->find_user_by_login($login);
|
|
|
|
|
|
|
|
if (!$user_id) {
|
2013-04-17 14:34:18 +00:00
|
|
|
$login = db_escape_string($login);
|
2012-08-16 11:30:35 +00:00
|
|
|
$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
|
|
|
|
$pwd_hash = encrypt_password($password, $salt, true);
|
|
|
|
|
|
|
|
$query = "INSERT INTO ttrss_users
|
|
|
|
(login,access_level,last_login,created,pwd_hash,salt)
|
|
|
|
VALUES ('$login', 0, null, NOW(), '$pwd_hash','$salt')";
|
|
|
|
|
2013-04-17 14:34:18 +00:00
|
|
|
db_query($query);
|
2012-08-16 11:30:35 +00:00
|
|
|
|
|
|
|
return $this->find_user_by_login($login);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return $user_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-16 11:38:33 +00:00
|
|
|
return $this->find_user_by_login($login);
|
2012-08-16 11:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function find_user_by_login($login) {
|
2013-04-17 14:34:18 +00:00
|
|
|
$login = db_escape_string($login);
|
2012-08-16 11:30:35 +00:00
|
|
|
|
2013-04-17 14:34:18 +00:00
|
|
|
$result = db_query("SELECT id FROM ttrss_users WHERE
|
2012-08-16 11:30:35 +00:00
|
|
|
login = '$login'");
|
|
|
|
|
|
|
|
if (db_num_rows($result) > 0) {
|
|
|
|
return db_fetch_result($result, 0, "id");
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|