| @@ 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 | { |
|
| @@ 380-395 (lines=16) @@ | ||
| 377 | return 1 === $stmt->rowCount(); |
|
| 378 | } |
|
| 379 | ||
| 380 | public function getLogEntry($dateTimeUnix, $ipAddress) |
|
| 381 | { |
|
| 382 | $stmt = $this->db->prepare( |
|
| 383 | 'SELECT profile_id, common_name, ip4, ip6, connected_at, disconnected_at |
|
| 384 | FROM connection_log |
|
| 385 | WHERE |
|
| 386 | (ip4 = :ip_address OR ip6 = :ip_address) |
|
| 387 | AND connected_at < :date_time_unix |
|
| 388 | AND (disconnected_at > :date_time_unix OR disconnected_at IS NULL)' |
|
| 389 | ); |
|
| 390 | $stmt->bindValue(':ip_address', $ipAddress, PDO::PARAM_STR); |
|
| 391 | $stmt->bindValue(':date_time_unix', $dateTimeUnix, PDO::PARAM_STR); |
|
| 392 | $stmt->execute(); |
|
| 393 | ||
| 394 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 395 | } |
|
| 396 | ||
| 397 | public function recordTotpKey($externalUserId, $totpKey, $timeUnix) |
|
| 398 | { |
|
| @@ 422-434 (lines=13) @@ | ||
| 419 | return 1 === $stmt->rowCount(); |
|
| 420 | } |
|
| 421 | ||
| 422 | public function cleanConnectionLog($timeUnix) |
|
| 423 | { |
|
| 424 | $stmt = $this->db->prepare( |
|
| 425 | sprintf( |
|
| 426 | 'DELETE FROM connection_log |
|
| 427 | WHERE connected_at < :time_unix' |
|
| 428 | ) |
|
| 429 | ); |
|
| 430 | ||
| 431 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 432 | ||
| 433 | return $stmt->execute(); |
|
| 434 | } |
|
| 435 | ||
| 436 | public function cleanTotpLog($timeUnix) |
|
| 437 | { |
|
| @@ 436-448 (lines=13) @@ | ||
| 433 | return $stmt->execute(); |
|
| 434 | } |
|
| 435 | ||
| 436 | public function cleanTotpLog($timeUnix) |
|
| 437 | { |
|
| 438 | $stmt = $this->db->prepare( |
|
| 439 | sprintf( |
|
| 440 | 'DELETE FROM totp_log |
|
| 441 | WHERE time_unix < :time_unix' |
|
| 442 | ) |
|
| 443 | ); |
|
| 444 | ||
| 445 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 446 | ||
| 447 | return $stmt->execute(); |
|
| 448 | } |
|
| 449 | ||
| 450 | public function motd() |
|
| 451 | { |
|