| @@ 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 | { |
|
| @@ 187-197 (lines=11) @@ | ||
| 184 | return 1 === $stmt->rowCount(); |
|
| 185 | } |
|
| 186 | ||
| 187 | public function deleteUser($externalUserId) |
|
| 188 | { |
|
| 189 | $stmt = $this->db->prepare( |
|
| 190 | 'DELETE FROM users WHERE external_user_id = :external_user_id' |
|
| 191 | ); |
|
| 192 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 193 | ||
| 194 | $stmt->execute(); |
|
| 195 | ||
| 196 | return 1 === $stmt->rowCount(); |
|
| 197 | } |
|
| 198 | ||
| 199 | public function addCertificate($externalUserId, $commonName, $displayName, $validFrom, $validTo) |
|
| 200 | { |
|
| @@ 241-251 (lines=11) @@ | ||
| 238 | return $certificateList; |
|
| 239 | } |
|
| 240 | ||
| 241 | public function disableCertificate($commonName) |
|
| 242 | { |
|
| 243 | $stmt = $this->db->prepare( |
|
| 244 | 'UPDATE certificates SET is_disabled = 1 WHERE common_name = :common_name' |
|
| 245 | ); |
|
| 246 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 247 | ||
| 248 | $stmt->execute(); |
|
| 249 | ||
| 250 | return 1 === $stmt->rowCount(); |
|
| 251 | } |
|
| 252 | ||
| 253 | public function enableCertificate($commonName) |
|
| 254 | { |
|
| @@ 253-263 (lines=11) @@ | ||
| 250 | return 1 === $stmt->rowCount(); |
|
| 251 | } |
|
| 252 | ||
| 253 | public function enableCertificate($commonName) |
|
| 254 | { |
|
| 255 | $stmt = $this->db->prepare( |
|
| 256 | 'UPDATE certificates SET is_disabled = 0 WHERE common_name = :common_name' |
|
| 257 | ); |
|
| 258 | $stmt->bindValue(':common_name', $commonName, PDO::PARAM_STR); |
|
| 259 | ||
| 260 | $stmt->execute(); |
|
| 261 | ||
| 262 | return 1 === $stmt->rowCount(); |
|
| 263 | } |
|
| 264 | ||
| 265 | public function disableUser($externalUserId) |
|
| 266 | { |
|
| @@ 265-277 (lines=13) @@ | ||
| 262 | return 1 === $stmt->rowCount(); |
|
| 263 | } |
|
| 264 | ||
| 265 | public function disableUser($externalUserId) |
|
| 266 | { |
|
| 267 | $stmt = $this->db->prepare( |
|
| 268 | 'UPDATE users SET is_disabled = 1 WHERE external_user_id = :external_user_id' |
|
| 269 | ); |
|
| 270 | $stmt->bindValue(':external_user_id', $externalUserId, PDO::PARAM_STR); |
|
| 271 | ||
| 272 | $stmt->execute(); |
|
| 273 | ||
| 274 | // XXX it seems on update the rowCount is always 1, even if nothing was |
|
| 275 | // modified? |
|
| 276 | return 1 === $stmt->rowCount(); |
|
| 277 | } |
|
| 278 | ||
| 279 | public function enableUser($externalUserId) |
|
| 280 | { |
|
| @@ 279-291 (lines=13) @@ | ||
| 276 | return 1 === $stmt->rowCount(); |
|
| 277 | } |
|
| 278 | ||
| 279 | public function enableUser($externalUserId) |
|
| 280 | { |
|
| 281 | $stmt = $this->db->prepare( |
|
| 282 | 'UPDATE users SET is_disabled = 0 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 isDisabledUser($externalUserId) |
|
| 294 | { |
|
| @@ 365-380 (lines=16) @@ | ||
| 362 | return 1 === $stmt->rowCount(); |
|
| 363 | } |
|
| 364 | ||
| 365 | public function getLogEntry($dateTimeUnix, $ipAddress) |
|
| 366 | { |
|
| 367 | $stmt = $this->db->prepare( |
|
| 368 | 'SELECT profile_id, common_name, ip4, ip6, connected_at, disconnected_at |
|
| 369 | FROM connection_log |
|
| 370 | WHERE |
|
| 371 | (ip4 = :ip_address OR ip6 = :ip_address) |
|
| 372 | AND connected_at < :date_time_unix |
|
| 373 | AND (disconnected_at > :date_time_unix OR disconnected_at IS NULL)' |
|
| 374 | ); |
|
| 375 | $stmt->bindValue(':ip_address', $ipAddress, PDO::PARAM_STR); |
|
| 376 | $stmt->bindValue(':date_time_unix', $dateTimeUnix, PDO::PARAM_STR); |
|
| 377 | $stmt->execute(); |
|
| 378 | ||
| 379 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 380 | } |
|
| 381 | ||
| 382 | public function recordTotpKey($externalUserId, $totpKey, $timeUnix) |
|
| 383 | { |
|
| @@ 407-419 (lines=13) @@ | ||
| 404 | return 1 === $stmt->rowCount(); |
|
| 405 | } |
|
| 406 | ||
| 407 | public function cleanConnectionLog($timeUnix) |
|
| 408 | { |
|
| 409 | $stmt = $this->db->prepare( |
|
| 410 | sprintf( |
|
| 411 | 'DELETE FROM connection_log |
|
| 412 | WHERE connected_at < :time_unix' |
|
| 413 | ) |
|
| 414 | ); |
|
| 415 | ||
| 416 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 417 | ||
| 418 | return $stmt->execute(); |
|
| 419 | } |
|
| 420 | ||
| 421 | public function cleanTotpLog($timeUnix) |
|
| 422 | { |
|
| @@ 421-433 (lines=13) @@ | ||
| 418 | return $stmt->execute(); |
|
| 419 | } |
|
| 420 | ||
| 421 | public function cleanTotpLog($timeUnix) |
|
| 422 | { |
|
| 423 | $stmt = $this->db->prepare( |
|
| 424 | sprintf( |
|
| 425 | 'DELETE FROM totp_log |
|
| 426 | WHERE time_unix < :time_unix' |
|
| 427 | ) |
|
| 428 | ); |
|
| 429 | ||
| 430 | $stmt->bindValue(':time_unix', $timeUnix, PDO::PARAM_INT); |
|
| 431 | ||
| 432 | return $stmt->execute(); |
|
| 433 | } |
|
| 434 | ||
| 435 | public function motd() |
|
| 436 | { |
|