| @@ 91-111 (lines=21) @@ | ||
| 88 | } |
|
| 89 | ||
| 90 | ||
| 91 | private function createCookie(Entity\CookieIdentity $entity) |
|
| 92 | { |
|
| 93 | $table = $this->config['accounts']['identities']; |
|
| 94 | $sql = "INSERT INTO {$table} |
|
| 95 | (user_id, type, status, identifier, fingerprint, hash, expires_on) |
|
| 96 | VALUES (:user, :type, :status, :series, :fingerprint, :hash, FROM_UNIXTIME(:expires))"; |
|
| 97 | ||
| 98 | $statement = $this->connection->prepare($sql); |
|
| 99 | ||
| 100 | $statement->bindValue(':user', $entity->getUserId()); |
|
| 101 | $statement->bindValue(':type', $entity->getType()); |
|
| 102 | $statement->bindValue(':status', $entity->getStatus()); |
|
| 103 | $statement->bindValue(':series', $entity->getSeries()); |
|
| 104 | $statement->bindValue(':fingerprint', $entity->getFingerprint()); |
|
| 105 | $statement->bindValue(':hash', $entity->getHash()); |
|
| 106 | $statement->bindValue(':expires', $entity->getExpiresOn()); |
|
| 107 | ||
| 108 | $statement->execute(); |
|
| 109 | ||
| 110 | $entity->setId($this->connection->lastInsertId()); |
|
| 111 | } |
|
| 112 | ||
| 113 | ||
| 114 | private function updateCookie(Entity\CookieIdentity $entity) |
|
| @@ 91-113 (lines=23) @@ | ||
| 88 | } |
|
| 89 | ||
| 90 | ||
| 91 | private function createIdentity(Entity\EmailIdentity $entity) |
|
| 92 | { |
|
| 93 | $table = $this->config['accounts']['identities']; |
|
| 94 | ||
| 95 | $sql = "INSERT INTO {$table} |
|
| 96 | (type, status, identifier, fingerprint, hash, token, token_action, token_expires_on ) |
|
| 97 | VALUES (:type, :status, :identifier, :fingerprint, :hash, :token, :action, FROM_UNIXTIME(:token_eol))"; |
|
| 98 | ||
| 99 | $statement = $this->connection->prepare($sql); |
|
| 100 | ||
| 101 | $statement->bindValue(':type', Entity\Identity::TYPE_PASSWORD); |
|
| 102 | $statement->bindValue(':status', Entity\Identity::STATUS_NEW); |
|
| 103 | $statement->bindValue(':identifier', $entity->getIdentifier()); |
|
| 104 | $statement->bindValue(':fingerprint', $entity->getFingerprint()); |
|
| 105 | $statement->bindValue(':hash', $entity->getHash()); |
|
| 106 | $statement->bindValue(':token', $entity->getToken()); |
|
| 107 | $statement->bindValue(':action', $entity->getTokenAction()); |
|
| 108 | $statement->bindValue(':token_eol', $entity->getTokenEndOfLife()); |
|
| 109 | ||
| 110 | $statement->execute(); |
|
| 111 | ||
| 112 | $entity->setId($this->connection->lastInsertId()); |
|
| 113 | } |
|
| 114 | ||
| 115 | ||
| 116 | private function updateIdentity(Entity\EmailIdentity $entity) |
|
| @@ 116-140 (lines=25) @@ | ||
| 113 | } |
|
| 114 | ||
| 115 | ||
| 116 | private function updateIdentity(Entity\EmailIdentity $entity) |
|
| 117 | { |
|
| 118 | $table = $this->config['accounts']['identities']; |
|
| 119 | ||
| 120 | $sql = "UPDATE {$table} |
|
| 121 | SET hash = :hash, |
|
| 122 | status = :status, |
|
| 123 | expires_on = FROM_UNIXTIME(:expires), |
|
| 124 | token = :token, |
|
| 125 | token_action = :action, |
|
| 126 | token_expires_on = FROM_UNIXTIME(:token_eol) |
|
| 127 | WHERE identity_id = :id"; |
|
| 128 | ||
| 129 | $statement = $this->connection->prepare($sql); |
|
| 130 | ||
| 131 | $statement->bindValue(':id', $entity->getId()); |
|
| 132 | $statement->bindValue(':hash', $entity->getHash()); |
|
| 133 | $statement->bindValue(':status', $entity->getStatus()); |
|
| 134 | $statement->bindValue(':expires', $entity->getExpiresOn()); |
|
| 135 | $statement->bindValue(':token', $entity->getToken()); |
|
| 136 | $statement->bindValue(':action', $entity->getTokenAction()); |
|
| 137 | $statement->bindValue(':token_eol', $entity->getTokenEndOfLife()); |
|
| 138 | ||
| 139 | $statement->execute(); |
|
| 140 | } |
|
| 141 | } |
|
| 142 | ||