| @@ 61-76 (lines=16) @@ | ||
| 58 | return $userList; |
|
| 59 | } |
|
| 60 | ||
| 61 | public function getUserCertificateInfo($commonName) |
|
| 62 | { |
|
| 63 | $stmt = $this->db->prepare( |
|
| 64 | 'SELECT |
|
| 65 | u.external_user_id AS user_id, |
|
| 66 | u.is_disabled AS user_is_disabled, |
|
| 67 | c.display_name AS display_name, |
|
| 68 | c.is_disabled AS certificate_is_disabled |
|
| 69 | FROM users u, certificates c |
|
| 70 | WHERE c.common_name = :common_name' |
|
| 71 | ); |
|
| 72 | ||
| 73 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 74 | $stmt->execute(); |
|
| 75 | ||
| 76 | return $stmt->fetch(PDO::FETCH_ASSOC); |
|
| 77 | } |
|
| 78 | ||
| 79 | private function getUserId($externalUserId) |
|
| @@ 202-212 (lines=11) @@ | ||
| 199 | return 1 === $stmt->rowCount(); |
|
| 200 | } |
|
| 201 | ||
| 202 | public function deleteUser($externalUserId) |
|
| 203 | { |
|
| 204 | $stmt = $this->db->prepare( |
|
| 205 | 'DELETE FROM users WHERE external_user_id = :external_user_id' |
|
| 206 | ); |
|
| 207 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 208 | ||
| 209 | $stmt->execute(); |
|
| 210 | ||
| 211 | return 1 === $stmt->rowCount(); |
|
| 212 | } |
|
| 213 | ||
| 214 | public function addCertificate($externalUserId, $commonName, $displayName, $validFrom, $validTo) |
|
| 215 | { |
|
| @@ 256-266 (lines=11) @@ | ||
| 253 | return $certificateList; |
|
| 254 | } |
|
| 255 | ||
| 256 | public function disableCertificate($commonName) |
|
| 257 | { |
|
| 258 | $stmt = $this->db->prepare( |
|
| 259 | 'UPDATE certificates SET is_disabled = 1 WHERE common_name = :common_name' |
|
| 260 | ); |
|
| 261 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 262 | ||
| 263 | $stmt->execute(); |
|
| 264 | ||
| 265 | return 1 === $stmt->rowCount(); |
|
| 266 | } |
|
| 267 | ||
| 268 | public function enableCertificate($commonName) |
|
| 269 | { |
|
| @@ 268-278 (lines=11) @@ | ||
| 265 | return 1 === $stmt->rowCount(); |
|
| 266 | } |
|
| 267 | ||
| 268 | public function enableCertificate($commonName) |
|
| 269 | { |
|
| 270 | $stmt = $this->db->prepare( |
|
| 271 | 'UPDATE certificates SET is_disabled = 0 WHERE common_name = :common_name' |
|
| 272 | ); |
|
| 273 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 274 | ||
| 275 | $stmt->execute(); |
|
| 276 | ||
| 277 | return 1 === $stmt->rowCount(); |
|
| 278 | } |
|
| 279 | ||
| 280 | public function disableUser($externalUserId) |
|
| 281 | { |
|
| @@ 280-292 (lines=13) @@ | ||
| 277 | return 1 === $stmt->rowCount(); |
|
| 278 | } |
|
| 279 | ||
| 280 | public function disableUser($externalUserId) |
|
| 281 | { |
|
| 282 | $stmt = $this->db->prepare( |
|
| 283 | 'UPDATE users SET is_disabled = 1 WHERE external_user_id = :external_user_id' |
|
| 284 | ); |
|
| 285 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 286 | ||
| 287 | $stmt->execute(); |
|
| 288 | ||
| 289 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 290 | // modified? |
|
| 291 | return 1 === $stmt->rowCount(); |
|
| 292 | } |
|
| 293 | ||
| 294 | public function enableUser($externalUserId) |
|
| 295 | { |
|
| @@ 294-306 (lines=13) @@ | ||
| 291 | return 1 === $stmt->rowCount(); |
|
| 292 | } |
|
| 293 | ||
| 294 | public function enableUser($externalUserId) |
|
| 295 | { |
|
| 296 | $stmt = $this->db->prepare( |
|
| 297 | 'UPDATE users SET is_disabled = 0 WHERE external_user_id = :external_user_id' |
|
| 298 | ); |
|
| 299 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 300 | ||
| 301 | $stmt->execute(); |
|
| 302 | ||
| 303 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 304 | // modified? |
|
| 305 | return 1 === $stmt->rowCount(); |
|
| 306 | } |
|
| 307 | ||
| 308 | public function isDisabledUser($externalUserId) |
|
| 309 | { |
|
| @@ 393-408 (lines=16) @@ | ||
| 390 | return 1 === $stmt->rowCount(); |
|
| 391 | } |
|
| 392 | ||
| 393 | public function getLogEntry($dateTimeUnix, $ipAddress) |
|
| 394 | { |
|
| 395 | $stmt = $this->db->prepare( |
|
| 396 | 'SELECT profile_id, common_name, ip4, ip6, connected_at, disconnected_at |
|
| 397 | FROM connection_log |
|
| 398 | WHERE |
|
| 399 | (ip4 = :ip_address OR ip6 = :ip_address) |
|
| 400 | AND connected_at < :date_time_unix |
|
| 401 | AND (disconnected_at > :date_time_unix OR disconnected_at IS NULL)' |
|
| 402 | ); |
|
| 403 | $stmt->bindValue(':ip_address', $ipAddress, PDO::PARAM_STR); |
|
| 404 | $stmt->bindValue(':date_time_unix', $dateTimeUnix, PDO::PARAM_STR); |
|
| 405 | $stmt->execute(); |
|
| 406 | ||
| 407 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 408 | } |
|
| 409 | ||
| 410 | public function recordTotpKey($externalUserId, $totpKey, $timeUnix) |
|
| 411 | { |
|
| @@ 435-447 (lines=13) @@ | ||
| 432 | return 1 === $stmt->rowCount(); |
|
| 433 | } |
|
| 434 | ||
| 435 | public function cleanConnectionLog($timeUnix) |
|
| 436 | { |
|
| 437 | $stmt = $this->db->prepare( |
|
| 438 | sprintf( |
|
| 439 | 'DELETE FROM connection_log |
|
| 440 | WHERE connected_at < :time_unix' |
|
| 441 | ) |
|
| 442 | ); |
|
| 443 | ||
| 444 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 445 | ||
| 446 | return $stmt->execute(); |
|
| 447 | } |
|
| 448 | ||
| 449 | public function cleanTotpLog($timeUnix) |
|
| 450 | { |
|
| @@ 449-461 (lines=13) @@ | ||
| 446 | return $stmt->execute(); |
|
| 447 | } |
|
| 448 | ||
| 449 | public function cleanTotpLog($timeUnix) |
|
| 450 | { |
|
| 451 | $stmt = $this->db->prepare( |
|
| 452 | sprintf( |
|
| 453 | 'DELETE FROM totp_log |
|
| 454 | WHERE time_unix < :time_unix' |
|
| 455 | ) |
|
| 456 | ); |
|
| 457 | ||
| 458 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 459 | ||
| 460 | return $stmt->execute(); |
|
| 461 | } |
|
| 462 | ||
| 463 | public function motd() |
|
| 464 | { |
|