geniv / nette-identity-registration
Nette 框架的身份注册扩展
v1.0.0
2018-04-17 07:43 UTC
Requires
- php: >=7.0.0
- geniv/nette-general-form: >=1.0.0
- nette/nette: >=2.4.0
This package is auto-updated.
Last update: 2024-09-14 04:03:43 UTC
README
安装
$ composer require geniv/nette-identity-registration
或者
"geniv/nette-identity-registration": ">=1.0.0"
require
"php": ">=7.0.0", "nette/nette": ">=2.4.0", "geniv/nette-general-form": ">=1.0.0"
包含在应用程序中
CleanUserEvent
& ApproveLinkEvent
validate 参数格式: https://php.ac.cn/manual/en/function.strtotime.php
ApproveLinkEvent
destination 参数是字符串,用于 $presenter->link()
neon 配置
# identity registration identityRegistration: # autowired: true # formContainer: Identity\Registration\FormContainer events: - Identity\Events\CleanUserEvent(-14 days) # clean non active user - CallbackEvent # check duplicity - SetValueEvent([active: false, role: guest]) # default value for registration - Identity\Events\RegistrationEvent # core registration - Identity\Events\ApproveLinkEvent(+1 hour, //link) # generate approve link admin: Identity\Events\EmailNotifyEvent # email for admin user: Identity\Events\EmailNotifyEvent # email for user
neon 配置扩展
extensions: identityRegistration: Identity\Registration\Bridges\Nette\Extension
presenter 使用
protected function createComponentIdentityRegistration(RegistrationForm $registrationForm): RegistrationForm { //$registrationForm->setTemplatePath(__DIR__ . '/templates/RegistrationForm.latte'); $registrationForm->onSuccess[] = function (array $values) { $this->flashMessage('Registration!', 'info'); $this->redirect('this'); }; $registrationForm->onException[] = function (RegistrationException $e) { $this->flashMessage('Registration exception! ' . $e->getMessage(), 'danger'); $this->redirect('this'); }; return $registrationForm; }
批准使用
public function actionApprove($h) { try { if ($this->identityModel->processApprove($h)) { $this->flashMessage('Approve!', 'info'); } } catch (IdentityException $e) { $this->flashMessage('Approve exception! ' . $e->getMessage(), 'danger'); } $this->redirect('default'); }
latte 使用
{control identityRegistration}