Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Improving UserToolsComponent::register()
Browse files Browse the repository at this point in the history
This fixes #23 as well.
  • Loading branch information
burzum committed Sep 28, 2015
1 parent f274860 commit 4d2e0e9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Controller/Component/UserToolComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,30 +496,25 @@ public function register($options = []) {
if ($options['enabled'] === false) {
throw new NotFoundException();
}
$return = false;
$entity = $this->UserTable->newEntity();
// Make the field accessible in the case the default entity class is used.
$entity->accessible('confirm_password', true);
if ($this->request->is('post')) {
$entity = $this->UserTable->patchEntity($entity, $this->request->data());
if ($this->UserTable->register($entity)) {
$this->handleFlashAndRedirect('success', $options);
if ($options['setEntity'] === true) {
$this->_controller->set('usersEntity', $entity);
}
return true;
$return = true;
} else {
$this->handleFlashAndRedirect('error', $options);
if ($options['setEntity'] === true) {
$this->_controller->set('usersEntity', $entity);
}
return false;
}
}
if ($options['setEntity'] === true) {
$this->_controller->set('userEntity', $entity);
// BC
// For backward compatibility
$this->_controller->set('usersEntity', $entity);
}
return $return;
}

/**
Expand Down Expand Up @@ -745,4 +740,4 @@ protected function _getAuthObject() {
}
}

}
}

0 comments on commit 4d2e0e9

Please sign in to comment.