예제 #1
0
 /**
  * Validate a validation code's validity, validly.
  *
  * @param Records $records
  * @param string  $code
  */
 public function validateCode(Records $records, $code)
 {
     $this->code = $code;
     if (strlen($code) !== 40) {
         $this->message = 'Invalid code';
         return;
     }
     // Get the verification key meta entity
     $metaEntities = $records->getAccountMetaValues(self::KEY_NAME, $code);
     if ($metaEntities === false) {
         $this->throwException(new AccountVerificationException('Stored meta code not found', AccountVerificationException::MISSING_META));
     }
     /** @var Storage\Entity\AccountMeta $metaEntity */
     $metaEntity = reset($metaEntities);
     if ($metaEntity === false) {
         $this->throwException(new AccountVerificationException('Stored meta code previously removed.', AccountVerificationException::REMOVED_META));
     }
     $guid = $metaEntity->getGuid();
     // Get the account and set it as verified
     $this->account = $records->getAccountByGuid($guid);
     if ($this->account === false) {
         $this->throwException(new AccountVerificationException('Missing account record.', AccountVerificationException::MISSING_ACCOUNT));
     }
     $this->account->setVerified(true);
     $records->saveAccount($this->account);
     // Remove meta record
     $records->deleteAccountMeta($metaEntity);
     $this->success = true;
     $this->message = 'Account validated!';
 }
예제 #2
0
 /**
  * Create and store the account record.
  *
  * @param Profile $entity
  *
  * @return Storage\Entity\Account
  */
 protected function createAccount(Profile $entity)
 {
     $displayName = $entity->getDisplayname();
     $emailAddress = $entity->getEmail();
     $account = $this->records->createAccount($displayName, $emailAddress, $this->config->getRolesRegister());
     $this->records->saveAccount($account);
     return $account;
 }
예제 #3
0
파일: Manager.php 프로젝트: bolt/Members
 /**
  * Delete a member account.
  *
  * @param string $guid
  * @param string $role
  *
  * @return bool
  */
 public function deleteAccountRole($guid, $role)
 {
     $account = $this->records->getAccountByGuid($guid);
     $roles = array_filter((array) $account->getRoles(), function ($r) use($role) {
         return $r !== $role ?: false;
     });
     $account->setRoles($roles);
     return $this->records->saveAccount($account);
 }