| @@ 61-76 (lines=16) @@ | ||
| 58 | return $userList; |
|
| 59 | } |
|
| 60 | ||
| 61 | public function getUserCertificateStatus($commonName) |
|
| 62 | { |
|
| 63 | $stmt = $this->db->prepare( |
|
| 64 | 'SELECT |
|
| 65 | u.external_user_id AS external_user_id, |
|
| 66 | u.is_disabled AS user_is_disabled, |
|
| 67 | c.is_disabled AS certificate_is_disabled |
|
| 68 | FROM users u, certificates c |
|
| 69 | WHERE c.common_name = :common_name' |
|
| 70 | ); |
|
| 71 | ||
| 72 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 73 | $stmt->execute(); |
|
| 74 | ||
| 75 | return $stmt->fetch(PDO::FETCH_ASSOC); |
|
| 76 | } |
|
| 77 | ||
| 78 | private function getUserId($externalUserId) |
|
| 79 | { |
|
| @@ 201-211 (lines=11) @@ | ||
| 198 | return 1 === $stmt->rowCount(); |
|
| 199 | } |
|
| 200 | ||
| 201 | public function deleteUser($externalUserId) |
|
| 202 | { |
|
| 203 | $stmt = $this->db->prepare( |
|
| 204 | 'DELETE FROM users WHERE external_user_id = :external_user_id' |
|
| 205 | ); |
|
| 206 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 207 | ||
| 208 | $stmt->execute(); |
|
| 209 | ||
| 210 | return 1 === $stmt->rowCount(); |
|
| 211 | } |
|
| 212 | ||
| 213 | public function addCertificate($externalUserId, $commonName, $displayName, $validFrom, $validTo) |
|
| 214 | { |
|
| @@ 255-265 (lines=11) @@ | ||
| 252 | return $certificateList; |
|
| 253 | } |
|
| 254 | ||
| 255 | public function disableCertificate($commonName) |
|
| 256 | { |
|
| 257 | $stmt = $this->db->prepare( |
|
| 258 | 'UPDATE certificates SET is_disabled = 1 WHERE common_name = :common_name' |
|
| 259 | ); |
|
| 260 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 261 | ||
| 262 | $stmt->execute(); |
|
| 263 | ||
| 264 | return 1 === $stmt->rowCount(); |
|
| 265 | } |
|
| 266 | ||
| 267 | public function enableCertificate($commonName) |
|
| 268 | { |
|
| @@ 267-277 (lines=11) @@ | ||
| 264 | return 1 === $stmt->rowCount(); |
|
| 265 | } |
|
| 266 | ||
| 267 | public function enableCertificate($commonName) |
|
| 268 | { |
|
| 269 | $stmt = $this->db->prepare( |
|
| 270 | 'UPDATE certificates SET is_disabled = 0 WHERE common_name = :common_name' |
|
| 271 | ); |
|
| 272 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 273 | ||
| 274 | $stmt->execute(); |
|
| 275 | ||
| 276 | return 1 === $stmt->rowCount(); |
|
| 277 | } |
|
| 278 | ||
| 279 | public function disableUser($externalUserId) |
|
| 280 | { |
|
| @@ 279-291 (lines=13) @@ | ||
| 276 | return 1 === $stmt->rowCount(); |
|
| 277 | } |
|
| 278 | ||
| 279 | public function disableUser($externalUserId) |
|
| 280 | { |
|
| 281 | $stmt = $this->db->prepare( |
|
| 282 | 'UPDATE users SET is_disabled = 1 WHERE external_user_id = :external_user_id' |
|
| 283 | ); |
|
| 284 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 285 | ||
| 286 | $stmt->execute(); |
|
| 287 | ||
| 288 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 289 | // modified? |
|
| 290 | return 1 === $stmt->rowCount(); |
|
| 291 | } |
|
| 292 | ||
| 293 | public function enableUser($externalUserId) |
|
| 294 | { |
|
| @@ 293-305 (lines=13) @@ | ||
| 290 | return 1 === $stmt->rowCount(); |
|
| 291 | } |
|
| 292 | ||
| 293 | public function enableUser($externalUserId) |
|
| 294 | { |
|
| 295 | $stmt = $this->db->prepare( |
|
| 296 | 'UPDATE users SET is_disabled = 0 WHERE external_user_id = :external_user_id' |
|
| 297 | ); |
|
| 298 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 299 | ||
| 300 | $stmt->execute(); |
|
| 301 | ||
| 302 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 303 | // modified? |
|
| 304 | return 1 === $stmt->rowCount(); |
|
| 305 | } |
|
| 306 | ||
| 307 | public function isDisabledUser($externalUserId) |
|
| 308 | { |
|
| @@ 379-394 (lines=16) @@ | ||
| 376 | return 1 === $stmt->rowCount(); |
|
| 377 | } |
|
| 378 | ||
| 379 | public function getLogEntry($dateTimeUnix, $ipAddress) |
|
| 380 | { |
|
| 381 | $stmt = $this->db->prepare( |
|
| 382 | 'SELECT profile_id, common_name, ip4, ip6, connected_at, disconnected_at |
|
| 383 | FROM connection_log |
|
| 384 | WHERE |
|
| 385 | (ip4 = :ip_address OR ip6 = :ip_address) |
|
| 386 | AND connected_at < :date_time_unix |
|
| 387 | AND (disconnected_at > :date_time_unix OR disconnected_at IS NULL)' |
|
| 388 | ); |
|
| 389 | $stmt->bindValue(':ip_address', $ipAddress, PDO::PARAM_STR); |
|
| 390 | $stmt->bindValue(':date_time_unix', $dateTimeUnix, PDO::PARAM_STR); |
|
| 391 | $stmt->execute(); |
|
| 392 | ||
| 393 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 394 | } |
|
| 395 | ||
| 396 | public function recordTotpKey($externalUserId, $totpKey, $timeUnix) |
|
| 397 | { |
|
| @@ 421-433 (lines=13) @@ | ||
| 418 | return 1 === $stmt->rowCount(); |
|
| 419 | } |
|
| 420 | ||
| 421 | public function cleanConnectionLog($timeUnix) |
|
| 422 | { |
|
| 423 | $stmt = $this->db->prepare( |
|
| 424 | sprintf( |
|
| 425 | 'DELETE FROM connection_log |
|
| 426 | WHERE connected_at < :time_unix' |
|
| 427 | ) |
|
| 428 | ); |
|
| 429 | ||
| 430 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 431 | ||
| 432 | return $stmt->execute(); |
|
| 433 | } |
|
| 434 | ||
| 435 | public function cleanTotpLog($timeUnix) |
|
| 436 | { |
|
| @@ 435-447 (lines=13) @@ | ||
| 432 | return $stmt->execute(); |
|
| 433 | } |
|
| 434 | ||
| 435 | public function cleanTotpLog($timeUnix) |
|
| 436 | { |
|
| 437 | $stmt = $this->db->prepare( |
|
| 438 | sprintf( |
|
| 439 | 'DELETE FROM totp_log |
|
| 440 | WHERE time_unix < :time_unix' |
|
| 441 | ) |
|
| 442 | ); |
|
| 443 | ||
| 444 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 445 | ||
| 446 | return $stmt->execute(); |
|
| 447 | } |
|
| 448 | ||
| 449 | public function motd() |
|
| 450 | { |
|