Conditions | 6 |
Paths | 5 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
13 | public function auto_create_user($login, $password = false) { |
||
14 | if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
||
|
|||
15 | $user_id = $this->find_user_by_login($login); |
||
16 | |||
17 | if (!$password) { |
||
18 | $password = make_password(); |
||
19 | } |
||
20 | |||
21 | if (!$user_id) { |
||
22 | $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
||
23 | $pwd_hash = encrypt_password($password, $salt, true); |
||
24 | |||
25 | $sth = $this->pdo->prepare("INSERT INTO ttrss_users |
||
26 | (login,access_level,last_login,created,pwd_hash,salt) |
||
27 | VALUES (?, 0, null, NOW(), ?,?)"); |
||
28 | $sth->execute([$login, $pwd_hash, $salt]); |
||
29 | |||
30 | return $this->find_user_by_login($login); |
||
31 | |||
32 | } else { |
||
33 | return $user_id; |
||
34 | } |
||
35 | } |
||
36 | |||
37 | return $this->find_user_by_login($login); |
||
38 | } |
||
51 |