| @@ 69-87 (lines=19) @@ | ||
| 66 | } |
|
| 67 | ||
| 68 | ||
| 69 | private function createCookie(Entity\CookieIdentity $entity) |
|
| 70 | { |
|
| 71 | $sql = "INSERT INTO {$this->table} |
|
| 72 | (account_id, parent_id, type, status, identifier, fingerprint, hash, created_on, expires_on) |
|
| 73 | VALUES (:account, :parent, :type, :status, :identifier, :fingerprint, :hash, :created, :expires)"; |
|
| 74 | ||
| 75 | $statement = $this->connection->prepare($sql); |
|
| 76 | ||
| 77 | $statement->bindValue(':parent', $entity->getParentId()); |
|
| 78 | $statement->bindValue(':hash', $entity->getHash()); |
|
| 79 | $statement->bindValue(':expires', $entity->getExpiresOn()); |
|
| 80 | $statement->bindValue(':created', time()); |
|
| 81 | ||
| 82 | $this->bindCommonParameters($statement, $entity); |
|
| 83 | ||
| 84 | $statement->execute(); |
|
| 85 | ||
| 86 | $entity->setId($this->connection->lastInsertId()); |
|
| 87 | } |
|
| 88 | ||
| 89 | ||
| 90 | private function updateCookie(Entity\CookieIdentity $entity) |
|
| @@ 89-115 (lines=27) @@ | ||
| 86 | } |
|
| 87 | ||
| 88 | ||
| 89 | private function fetchByToken(Entity\Identity $entity) |
|
| 90 | { |
|
| 91 | $sql = "SELECT identity_id AS id, |
|
| 92 | parent_id AS parentId, |
|
| 93 | account_id AS accountId, |
|
| 94 | status AS status, |
|
| 95 | hash AS hash, |
|
| 96 | token_expires_on AS tokenEndOfLife |
|
| 97 | FROM {$this->table} |
|
| 98 | WHERE token = :token |
|
| 99 | AND token_action = :action |
|
| 100 | AND token_expires_on > :expires"; |
|
| 101 | ||
| 102 | $statement = $this->connection->prepare($sql); |
|
| 103 | ||
| 104 | $statement->bindValue(':token', $entity->getToken()); |
|
| 105 | $statement->bindValue(':action', $entity->getTokenAction()); |
|
| 106 | $statement->bindValue(':expires', $entity->getTokenEndOfLife()); |
|
| 107 | ||
| 108 | $statement->execute(); |
|
| 109 | ||
| 110 | $data = $statement->fetch(PDO::FETCH_ASSOC); |
|
| 111 | ||
| 112 | if ($data) { |
|
| 113 | $this->applyValues($entity, $data); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | } |
|
| 117 | ||
| @@ 57-84 (lines=28) @@ | ||
| 54 | } |
|
| 55 | ||
| 56 | ||
| 57 | private function fetchByEmailAddress(Entity\EmailIdentity $entity) |
|
| 58 | { |
|
| 59 | $sql = "SELECT identity_id AS id, |
|
| 60 | account_id AS accountId, |
|
| 61 | hash AS hash, |
|
| 62 | status AS status, |
|
| 63 | used_on AS lastUsed, |
|
| 64 | token AS token, |
|
| 65 | token_action AS tokenAction, |
|
| 66 | token_expires_on AS tokenEndOfLife |
|
| 67 | FROM {$this->table} |
|
| 68 | WHERE type = :type |
|
| 69 | AND fingerprint = :fingerprint |
|
| 70 | AND identifier = :email"; |
|
| 71 | ||
| 72 | $statement = $this->connection->prepare($sql); |
|
| 73 | ||
| 74 | $statement->bindValue(':type', $entity->getType()); |
|
| 75 | $statement->bindValue(':email', $entity->getEmailAddress()); |
|
| 76 | $statement->bindValue(':fingerprint', $entity->getFingerprint()); |
|
| 77 | ||
| 78 | $statement->execute(); |
|
| 79 | ||
| 80 | $data = $statement->fetch(PDO::FETCH_ASSOC); |
|
| 81 | ||
| 82 | if ($data) { |
|
| 83 | $this->applyValues($entity, $data); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | ||
| 87 | ||
| @@ 88-114 (lines=27) @@ | ||
| 85 | } |
|
| 86 | ||
| 87 | ||
| 88 | private function fetchById(Entity\EmailIdentity $entity) |
|
| 89 | { |
|
| 90 | $sql = "SELECT identity_id AS id, |
|
| 91 | account_id AS accountId, |
|
| 92 | hash AS hash, |
|
| 93 | status AS status, |
|
| 94 | used_on AS lastUsed, |
|
| 95 | token AS token, |
|
| 96 | token_action AS tokenAction, |
|
| 97 | token_expires_on AS tokenEndOfLife |
|
| 98 | FROM {$this->table} |
|
| 99 | WHERE type = :type |
|
| 100 | AND identity_id = :id"; |
|
| 101 | ||
| 102 | $statement = $this->connection->prepare($sql); |
|
| 103 | ||
| 104 | $statement->bindValue(':type', $entity->getType()); |
|
| 105 | $statement->bindValue(':id', $entity->getId()); |
|
| 106 | ||
| 107 | $statement->execute(); |
|
| 108 | ||
| 109 | $data = $statement->fetch(PDO::FETCH_ASSOC); |
|
| 110 | ||
| 111 | if ($data) { |
|
| 112 | $this->applyValues($entity, $data); |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||
| 116 | ||
| 117 | /** |
|