Conditions | 6 |
Paths | 5 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
13 | 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) $password = make_password(); |
||
18 | |||
19 | if (!$user_id) { |
||
20 | $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
||
21 | $pwd_hash = encrypt_password($password, $salt, true); |
||
22 | |||
23 | $sth = $this->pdo->prepare("INSERT INTO ttrss_users |
||
24 | (login,access_level,last_login,created,pwd_hash,salt) |
||
25 | VALUES (?, 0, null, NOW(), ?,?)"); |
||
26 | $sth->execute([$login, $pwd_hash, $salt]); |
||
27 | |||
28 | return $this->find_user_by_login($login); |
||
29 | |||
30 | } else { |
||
31 | return $user_id; |
||
32 | } |
||
33 | } |
||
34 | |||
35 | return $this->find_user_by_login($login); |
||
36 | } |
||
49 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.