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