]>
git.wh0rd.org - tt-rss.git/blob - classes/auth/base.php
6 function __construct() {
7 $this->dbh
= Db
::get();
8 $this->pdo
= Db
::pdo();
12 * @SuppressWarnings(unused)
14 function check_password($owner_uid, $password) {
19 * @SuppressWarnings(unused)
21 function authenticate($login, $password) {
25 // Auto-creates specified user if allowed by system configuration
26 // Can be used instead of find_user_by_login() by external auth modules
27 function auto_create_user($login, $password = false) {
28 if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE
) {
29 $user_id = $this->find_user_by_login($login);
31 if (!$password) $password = make_password();
34 $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
35 $pwd_hash = encrypt_password($password, $salt, true);
37 $sth = $this->pdo
->prepare("INSERT INTO ttrss_users
38 (login,access_level,last_login,created,pwd_hash,salt)
39 VALUES (?, 0, null, NOW(), ?,?)");
40 $sth->execute([$login, $pwd_hash, $salt]);
42 return $this->find_user_by_login($login);
49 return $this->find_user_by_login($login);
52 function find_user_by_login($login) {
53 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_users WHERE
55 $sth->execute([$login]);
57 if ($row = $sth->fetch()) {