| @@ 123-140 (lines=18) @@ | ||
| 120 | return $stmt->fetch(PDO::FETCH_ASSOC); |
|
| 121 | } |
|
| 122 | ||
| 123 | public function getVootToken($userId) |
|
| 124 | { |
|
| 125 | $userId = $this->getId($userId); |
|
| 126 | $stmt = $this->db->prepare( |
|
| 127 | <<< 'SQL' |
|
| 128 | SELECT |
|
| 129 | voot_token |
|
| 130 | FROM |
|
| 131 | voot_tokens |
|
| 132 | WHERE |
|
| 133 | user_id = :user_id |
|
| 134 | SQL |
|
| 135 | ); |
|
| 136 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 137 | $stmt->execute(); |
|
| 138 | ||
| 139 | return $stmt->fetchColumn(); |
|
| 140 | } |
|
| 141 | ||
| 142 | public function setVootToken($userId, $vootToken) |
|
| 143 | { |
|
| @@ 218-235 (lines=18) @@ | ||
| 215 | return 1 === (int) $stmt->fetchColumn(); |
|
| 216 | } |
|
| 217 | ||
| 218 | public function getTotpSecret($userId) |
|
| 219 | { |
|
| 220 | $userId = $this->getId($userId); |
|
| 221 | $stmt = $this->db->prepare( |
|
| 222 | <<< 'SQL' |
|
| 223 | SELECT |
|
| 224 | totp_secret |
|
| 225 | FROM |
|
| 226 | totp_secrets |
|
| 227 | WHERE |
|
| 228 | user_id = :user_id |
|
| 229 | SQL |
|
| 230 | ); |
|
| 231 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 232 | $stmt->execute(); |
|
| 233 | ||
| 234 | return $stmt->fetchColumn(); |
|
| 235 | } |
|
| 236 | ||
| 237 | public function setTotpSecret($userId, $totpSecret) |
|
| 238 | { |
|
| @@ 606-623 (lines=18) @@ | ||
| 603 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 604 | } |
|
| 605 | ||
| 606 | public function getTotpAttemptCount($userId) |
|
| 607 | { |
|
| 608 | $userId = $this->getId($userId); |
|
| 609 | $stmt = $this->db->prepare( |
|
| 610 | <<< 'SQL' |
|
| 611 | SELECT |
|
| 612 | COUNT(*) |
|
| 613 | FROM |
|
| 614 | totp_log |
|
| 615 | WHERE user_id = :user_id |
|
| 616 | SQL |
|
| 617 | ); |
|
| 618 | ||
| 619 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 620 | $stmt->execute(); |
|
| 621 | ||
| 622 | return (int) $stmt->fetchColumn(); |
|
| 623 | } |
|
| 624 | ||
| 625 | public function recordTotpKey($userId, $totpKey, DateTime $dateTime) |
|
| 626 | { |
|
| @@ 755-776 (lines=22) @@ | ||
| 752 | return 1 === $stmt->rowCount(); |
|
| 753 | } |
|
| 754 | ||
| 755 | public function userMessages($userId) |
|
| 756 | { |
|
| 757 | $userId = $this->getId($userId); |
|
| 758 | ||
| 759 | $stmt = $this->db->prepare( |
|
| 760 | <<< 'SQL' |
|
| 761 | SELECT |
|
| 762 | id, type, message, date_time |
|
| 763 | FROM |
|
| 764 | user_messages |
|
| 765 | WHERE |
|
| 766 | user_id = :user_id |
|
| 767 | ORDER BY |
|
| 768 | date_time DESC |
|
| 769 | SQL |
|
| 770 | ); |
|
| 771 | ||
| 772 | $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); |
|
| 773 | $stmt->execute(); |
|
| 774 | ||
| 775 | return $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 776 | } |
|
| 777 | ||
| 778 | public function addUserMessage($userId, $type, $message, DateTime $dateTime) |
|
| 779 | { |
|