| @@ 88-113 (lines=26) @@ | ||
| 85 | } |
|
| 86 | ||
| 87 | ||
| 88 | private function fetchByToken(Entity\Identity $entity) |
|
| 89 | { |
|
| 90 | $sql = "SELECT identity_id AS id, |
|
| 91 | parent_id AS parentId, |
|
| 92 | account_id AS accountId, |
|
| 93 | status AS status, |
|
| 94 | hash AS hash, |
|
| 95 | token_expires_on AS tokenEndOfLife |
|
| 96 | FROM {$this->table} |
|
| 97 | WHERE token = :token |
|
| 98 | AND token_action = :action |
|
| 99 | AND token_expires_on > :expires"; |
|
| 100 | ||
| 101 | $statement = $this->connection->prepare($sql); |
|
| 102 | ||
| 103 | $statement->bindValue(':token', $entity->getToken()); |
|
| 104 | $statement->bindValue(':action', $entity->getTokenAction()); |
|
| 105 | $statement->bindValue(':expires', $entity->getTokenEndOfLife()); |
|
| 106 | ||
| 107 | $statement->execute(); |
|
| 108 | ||
| 109 | $data = $statement->fetch(); |
|
| 110 | ||
| 111 | if ($data) { |
|
| 112 | $this->applyValues($entity, $data); |
|
| 113 | } |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||
| @@ 45-72 (lines=28) @@ | ||
| 42 | /** |
|
| 43 | * @param Entity\EmailIdentity $entity |
|
| 44 | */ |
|
| 45 | public function fetch(Entity\EmailIdentity $entity) |
|
| 46 | { |
|
| 47 | $sql = "SELECT identity_id AS id, |
|
| 48 | account_id AS accountId, |
|
| 49 | hash AS hash, |
|
| 50 | status AS status, |
|
| 51 | token AS token, |
|
| 52 | token_action AS tokenAction, |
|
| 53 | token_expires_on AS tokenEndOfLife |
|
| 54 | FROM {$this->table} |
|
| 55 | WHERE type = :type |
|
| 56 | AND fingerprint = :fingerprint |
|
| 57 | AND identifier = :email"; |
|
| 58 | ||
| 59 | $statement = $this->connection->prepare($sql); |
|
| 60 | ||
| 61 | $statement->bindValue(':type', $entity->getType()); |
|
| 62 | $statement->bindValue(':email', $entity->getEmailAddress()); |
|
| 63 | $statement->bindValue(':fingerprint', $entity->getFingerprint()); |
|
| 64 | ||
| 65 | $statement->execute(); |
|
| 66 | ||
| 67 | $data = $statement->fetch(); |
|
| 68 | ||
| 69 | if ($data) { |
|
| 70 | $this->applyValues($entity, $data); |
|
| 71 | } |
|
| 72 | } |
|
| 73 | ||
| 74 | ||
| 75 | /** |
|
| @@ 19-44 (lines=26) @@ | ||
| 16 | /** |
|
| 17 | * @param Entity\OneTimeIdentity $entity |
|
| 18 | */ |
|
| 19 | public function fetch(Entity\OneTimeIdentity $entity) |
|
| 20 | { |
|
| 21 | $status = Entity\Identity::STATUS_ACTIVE; |
|
| 22 | ||
| 23 | $sql = "SELECT identity_id AS id, |
|
| 24 | account_id AS accountId, |
|
| 25 | hash AS hash, |
|
| 26 | status AS status |
|
| 27 | FROM {$this->table} |
|
| 28 | WHERE type = :type |
|
| 29 | AND status = {$status} |
|
| 30 | AND identifier = :nonce"; |
|
| 31 | ||
| 32 | $statement = $this->connection->prepare($sql); |
|
| 33 | ||
| 34 | $statement->bindValue(':nonce', $entity->getEmailAddress()); |
|
| 35 | $statement->bindValue(':type', $entity->getType()); |
|
| 36 | ||
| 37 | $statement->execute(); |
|
| 38 | ||
| 39 | $data = $statement->fetch(); |
|
| 40 | ||
| 41 | if ($data) { |
|
| 42 | $this->applyValues($entity, $data); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| 46 | ||
| 47 | /** |
|