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