| @@ 62-77 (lines=16) @@ | ||
| 59 | return $userList; |
|
| 60 | } |
|
| 61 | ||
| 62 | public function getUserCertificateInfo($commonName) |
|
| 63 | { |
|
| 64 | $stmt = $this->db->prepare( |
|
| 65 | 'SELECT |
|
| 66 | u.external_user_id AS user_id, |
|
| 67 | u.is_disabled AS user_is_disabled, |
|
| 68 | c.display_name AS display_name, |
|
| 69 | c.is_disabled AS certificate_is_disabled |
|
| 70 | FROM users u, certificates c |
|
| 71 | WHERE c.common_name = :common_name' |
|
| 72 | ); |
|
| 73 | ||
| 74 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 75 | $stmt->execute(); |
|
| 76 | ||
| 77 | return $stmt->fetch(PDO::FETCH_ASSOC); |
|
| 78 | } |
|
| 79 | ||
| 80 | private function getUserId($externalUserId) |
|
| @@ 208-218 (lines=11) @@ | ||
| 205 | return 1 === $stmt->rowCount(); |
|
| 206 | } |
|
| 207 | ||
| 208 | public function deleteUser($externalUserId) |
|
| 209 | { |
|
| 210 | $stmt = $this->db->prepare( |
|
| 211 | 'DELETE FROM users WHERE external_user_id = :external_user_id' |
|
| 212 | ); |
|
| 213 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 214 | ||
| 215 | $stmt->execute(); |
|
| 216 | ||
| 217 | return 1 === $stmt->rowCount(); |
|
| 218 | } |
|
| 219 | ||
| 220 | public function addCertificate($externalUserId, $commonName, $displayName, $validFrom, $validTo) |
|
| 221 | { |
|
| @@ 262-272 (lines=11) @@ | ||
| 259 | return $certificateList; |
|
| 260 | } |
|
| 261 | ||
| 262 | public function disableCertificate($commonName) |
|
| 263 | { |
|
| 264 | $stmt = $this->db->prepare( |
|
| 265 | 'UPDATE certificates SET is_disabled = 1 WHERE common_name = :common_name' |
|
| 266 | ); |
|
| 267 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 268 | ||
| 269 | $stmt->execute(); |
|
| 270 | ||
| 271 | return 1 === $stmt->rowCount(); |
|
| 272 | } |
|
| 273 | ||
| 274 | public function enableCertificate($commonName) |
|
| 275 | { |
|
| @@ 274-284 (lines=11) @@ | ||
| 271 | return 1 === $stmt->rowCount(); |
|
| 272 | } |
|
| 273 | ||
| 274 | public function enableCertificate($commonName) |
|
| 275 | { |
|
| 276 | $stmt = $this->db->prepare( |
|
| 277 | 'UPDATE certificates SET is_disabled = 0 WHERE common_name = :common_name' |
|
| 278 | ); |
|
| 279 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 280 | ||
| 281 | $stmt->execute(); |
|
| 282 | ||
| 283 | return 1 === $stmt->rowCount(); |
|
| 284 | } |
|
| 285 | ||
| 286 | public function disableUser($externalUserId) |
|
| 287 | { |
|
| @@ 286-298 (lines=13) @@ | ||
| 283 | return 1 === $stmt->rowCount(); |
|
| 284 | } |
|
| 285 | ||
| 286 | public function disableUser($externalUserId) |
|
| 287 | { |
|
| 288 | $stmt = $this->db->prepare( |
|
| 289 | 'UPDATE users SET is_disabled = 1 WHERE external_user_id = :external_user_id' |
|
| 290 | ); |
|
| 291 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 292 | ||
| 293 | $stmt->execute(); |
|
| 294 | ||
| 295 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 296 | // modified? |
|
| 297 | return 1 === $stmt->rowCount(); |
|
| 298 | } |
|
| 299 | ||
| 300 | public function enableUser($externalUserId) |
|
| 301 | { |
|
| @@ 300-312 (lines=13) @@ | ||
| 297 | return 1 === $stmt->rowCount(); |
|
| 298 | } |
|
| 299 | ||
| 300 | public function enableUser($externalUserId) |
|
| 301 | { |
|
| 302 | $stmt = $this->db->prepare( |
|
| 303 | 'UPDATE users SET is_disabled = 0 WHERE external_user_id = :external_user_id' |
|
| 304 | ); |
|
| 305 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 306 | ||
| 307 | $stmt->execute(); |
|
| 308 | ||
| 309 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 310 | // modified? |
|
| 311 | return 1 === $stmt->rowCount(); |
|
| 312 | } |
|
| 313 | ||
| 314 | public function isDisabledUser($externalUserId) |
|
| 315 | { |
|
| @@ 399-414 (lines=16) @@ | ||
| 396 | return 1 === $stmt->rowCount(); |
|
| 397 | } |
|
| 398 | ||
| 399 | public function getLogEntry($dateTimeUnix, $ipAddress) |
|
| 400 | { |
|
| 401 | $stmt = $this->db->prepare( |
|
| 402 | 'SELECT profile_id, common_name, ip4, ip6, connected_at, disconnected_at |
|
| 403 | FROM connection_log |
|
| 404 | WHERE |
|
| 405 | (ip4 = :ip_address OR ip6 = :ip_address) |
|
| 406 | AND connected_at < :date_time_unix |
|
| 407 | AND (disconnected_at > :date_time_unix OR disconnected_at IS NULL)' |
|
| 408 | ); |
|
| 409 | $stmt->bindValue(':ip_address', $ipAddress, PDO::PARAM_STR); |
|
| 410 | $stmt->bindValue(':date_time_unix', $dateTimeUnix, PDO::PARAM_STR); |
|
| 411 | $stmt->execute(); |
|
| 412 | ||
| 413 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 414 | } |
|
| 415 | ||
| 416 | public function recordTotpKey($externalUserId, $totpKey, $timeUnix) |
|
| 417 | { |
|
| @@ 446-458 (lines=13) @@ | ||
| 443 | return true; |
|
| 444 | } |
|
| 445 | ||
| 446 | public function cleanConnectionLog($timeUnix) |
|
| 447 | { |
|
| 448 | $stmt = $this->db->prepare( |
|
| 449 | sprintf( |
|
| 450 | 'DELETE FROM connection_log |
|
| 451 | WHERE connected_at < :time_unix' |
|
| 452 | ) |
|
| 453 | ); |
|
| 454 | ||
| 455 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 456 | ||
| 457 | return $stmt->execute(); |
|
| 458 | } |
|
| 459 | ||
| 460 | public function cleanTotpLog($timeUnix) |
|
| 461 | { |
|
| @@ 460-472 (lines=13) @@ | ||
| 457 | return $stmt->execute(); |
|
| 458 | } |
|
| 459 | ||
| 460 | public function cleanTotpLog($timeUnix) |
|
| 461 | { |
|
| 462 | $stmt = $this->db->prepare( |
|
| 463 | sprintf( |
|
| 464 | 'DELETE FROM totp_log |
|
| 465 | WHERE time_unix < :time_unix' |
|
| 466 | ) |
|
| 467 | ); |
|
| 468 | ||
| 469 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 470 | ||
| 471 | return $stmt->execute(); |
|
| 472 | } |
|
| 473 | ||
| 474 | public function motd() |
|
| 475 | { |
|