Conditions | 12 |
Paths | 152 |
Total Lines | 45 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
43 | public function authenticate($login, $password) { |
||
44 | $try_login = $_SERVER["REMOTE_USER"]; |
||
45 | |||
46 | // php-cgi |
||
47 | if (!$try_login) { |
||
48 | $try_login = $_SERVER["REDIRECT_REMOTE_USER"]; |
||
49 | } |
||
50 | if (!$try_login) { |
||
51 | $try_login = $_SERVER["PHP_AUTH_USER"]; |
||
52 | } |
||
53 | |||
54 | if (!$try_login) { |
||
55 | $try_login = $this->get_login_by_ssl_certificate(); |
||
56 | } |
||
57 | |||
58 | if ($try_login) { |
||
59 | $user_id = $this->base->auto_create_user($try_login, $password); |
||
60 | |||
61 | if ($user_id) { |
||
62 | $_SESSION["fake_login"] = $try_login; |
||
63 | $_SESSION["fake_password"] = "******"; |
||
64 | $_SESSION["hide_hello"] = true; |
||
65 | $_SESSION["hide_logout"] = true; |
||
66 | |||
67 | // LemonLDAP can send user informations via HTTP HEADER |
||
68 | if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
||
|
|||
69 | // update user name |
||
70 | $fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN']; |
||
71 | if ($fullname) { |
||
72 | $sth = $this->pdo->prepare("UPDATE ttrss_users SET full_name = ? WHERE id = ?"); |
||
73 | $sth->execute([$fullname, $user_id]); |
||
74 | } |
||
75 | // update user mail |
||
76 | $email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL']; |
||
77 | if ($email) { |
||
78 | $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ? WHERE id = ?"); |
||
79 | $sth->execute([$email, $user_id]); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | return $user_id; |
||
84 | } |
||
85 | } |
||
86 | |||
87 | return false; |
||
88 | } |
||
95 |