| @@ 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) |
|
| @@ 222-232 (lines=11) @@ | ||
| 219 | return 1 === $stmt->rowCount(); |
|
| 220 | } |
|
| 221 | ||
| 222 | public function deleteUser($externalUserId) |
|
| 223 | { |
|
| 224 | $stmt = $this->db->prepare( |
|
| 225 | 'DELETE FROM users WHERE external_user_id = :external_user_id' |
|
| 226 | ); |
|
| 227 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 228 | ||
| 229 | $stmt->execute(); |
|
| 230 | ||
| 231 | return 1 === $stmt->rowCount(); |
|
| 232 | } |
|
| 233 | ||
| 234 | public function addCertificate($externalUserId, $commonName, $displayName, $validFrom, $validTo) |
|
| 235 | { |
|
| @@ 276-286 (lines=11) @@ | ||
| 273 | return $certificateList; |
|
| 274 | } |
|
| 275 | ||
| 276 | public function disableCertificate($commonName) |
|
| 277 | { |
|
| 278 | $stmt = $this->db->prepare( |
|
| 279 | 'UPDATE certificates SET is_disabled = 1 WHERE common_name = :common_name' |
|
| 280 | ); |
|
| 281 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 282 | ||
| 283 | $stmt->execute(); |
|
| 284 | ||
| 285 | return 1 === $stmt->rowCount(); |
|
| 286 | } |
|
| 287 | ||
| 288 | public function enableCertificate($commonName) |
|
| 289 | { |
|
| @@ 288-298 (lines=11) @@ | ||
| 285 | return 1 === $stmt->rowCount(); |
|
| 286 | } |
|
| 287 | ||
| 288 | public function enableCertificate($commonName) |
|
| 289 | { |
|
| 290 | $stmt = $this->db->prepare( |
|
| 291 | 'UPDATE certificates SET is_disabled = 0 WHERE common_name = :common_name' |
|
| 292 | ); |
|
| 293 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 294 | ||
| 295 | $stmt->execute(); |
|
| 296 | ||
| 297 | return 1 === $stmt->rowCount(); |
|
| 298 | } |
|
| 299 | ||
| 300 | public function disableUser($externalUserId) |
|
| 301 | { |
|
| @@ 300-312 (lines=13) @@ | ||
| 297 | return 1 === $stmt->rowCount(); |
|
| 298 | } |
|
| 299 | ||
| 300 | public function disableUser($externalUserId) |
|
| 301 | { |
|
| 302 | $stmt = $this->db->prepare( |
|
| 303 | 'UPDATE users SET is_disabled = 1 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 enableUser($externalUserId) |
|
| 315 | { |
|
| @@ 314-326 (lines=13) @@ | ||
| 311 | return 1 === $stmt->rowCount(); |
|
| 312 | } |
|
| 313 | ||
| 314 | public function enableUser($externalUserId) |
|
| 315 | { |
|
| 316 | $stmt = $this->db->prepare( |
|
| 317 | 'UPDATE users SET is_disabled = 0 WHERE external_user_id = :external_user_id' |
|
| 318 | ); |
|
| 319 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 320 | ||
| 321 | $stmt->execute(); |
|
| 322 | ||
| 323 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 324 | // modified? |
|
| 325 | return 1 === $stmt->rowCount(); |
|
| 326 | } |
|
| 327 | ||
| 328 | public function isDisabledUser($externalUserId) |
|
| 329 | { |
|
| @@ 413-428 (lines=16) @@ | ||
| 410 | return 1 === $stmt->rowCount(); |
|
| 411 | } |
|
| 412 | ||
| 413 | public function getLogEntry($dateTimeUnix, $ipAddress) |
|
| 414 | { |
|
| 415 | $stmt = $this->db->prepare( |
|
| 416 | 'SELECT profile_id, common_name, ip4, ip6, connected_at, disconnected_at |
|
| 417 | FROM connection_log |
|
| 418 | WHERE |
|
| 419 | (ip4 = :ip_address OR ip6 = :ip_address) |
|
| 420 | AND connected_at < :date_time_unix |
|
| 421 | AND (disconnected_at > :date_time_unix OR disconnected_at IS NULL)' |
|
| 422 | ); |
|
| 423 | $stmt->bindValue(':ip_address', $ipAddress, PDO::PARAM_STR); |
|
| 424 | $stmt->bindValue(':date_time_unix', $dateTimeUnix, PDO::PARAM_STR); |
|
| 425 | $stmt->execute(); |
|
| 426 | ||
| 427 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 428 | } |
|
| 429 | ||
| 430 | public function recordTotpKey($externalUserId, $totpKey, $timeUnix) |
|
| 431 | { |
|
| @@ 460-472 (lines=13) @@ | ||
| 457 | return true; |
|
| 458 | } |
|
| 459 | ||
| 460 | public function cleanConnectionLog($timeUnix) |
|
| 461 | { |
|
| 462 | $stmt = $this->db->prepare( |
|
| 463 | sprintf( |
|
| 464 | 'DELETE FROM connection_log |
|
| 465 | WHERE connected_at < :time_unix' |
|
| 466 | ) |
|
| 467 | ); |
|
| 468 | ||
| 469 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 470 | ||
| 471 | return $stmt->execute(); |
|
| 472 | } |
|
| 473 | ||
| 474 | public function cleanTotpLog($timeUnix) |
|
| 475 | { |
|
| @@ 474-486 (lines=13) @@ | ||
| 471 | return $stmt->execute(); |
|
| 472 | } |
|
| 473 | ||
| 474 | public function cleanTotpLog($timeUnix) |
|
| 475 | { |
|
| 476 | $stmt = $this->db->prepare( |
|
| 477 | sprintf( |
|
| 478 | 'DELETE FROM totp_log |
|
| 479 | WHERE time_unix < :time_unix' |
|
| 480 | ) |
|
| 481 | ); |
|
| 482 | ||
| 483 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 484 | ||
| 485 | return $stmt->execute(); |
|
| 486 | } |
|
| 487 | ||
| 488 | public function motd() |
|
| 489 | { |
|