Close #68 fix documentation + events raised on User model
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.0.14 - Work in progress
|
||||
- Fix #68: Fix user events documentation and events raised from User model (tonydspaniard)
|
||||
- Fix #69: Log level when user can't register should be L_ERROR (tonydspaniard)
|
||||
- Enh #81: Update `AccessRuleFilter` to evaluate `roleParams` (kartik-v)
|
||||
- Enh #56: Added two factor authentication (tonydspaniard)
|
||||
|
||||
@ -14,6 +14,8 @@ On Controllers
|
||||
- **RegistrationController**
|
||||
- **FormEvent::EVENT_BEFORE_RESEND**: Occurs before a confirmation message is being sent via email
|
||||
- **FormEvent::EVENT_AFTER_RESEND**: Occurs after a confirmation message is being sent via email
|
||||
- **FormEvent::EVENT_BEFORE_REGISTER**: Occurs before user registration
|
||||
- **FormEvent::EVENT_AFTER_REGISTER**: Occurs after user registration
|
||||
|
||||
|
||||
- **SecurityController**
|
||||
|
||||
@ -22,8 +22,6 @@ On Controllers
|
||||
|
||||
|
||||
- **RegistrationController**
|
||||
- **UserEvent::EVENT_BEFORE_REGISTER**: Occurs before user registration
|
||||
- **UserEvent::EVENT_AFTER_REGISTER**: Occurs after user registration
|
||||
- **UserEvent::EVENT_BEFORE_CONFIRMATION**
|
||||
- **UserEvent::EVENT_AFTER_CONFIRMATION**
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ class RegistrationController extends Controller
|
||||
$this->make(AjaxRequestModelValidator::class, [$form])->validate();
|
||||
|
||||
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
|
||||
$this->trigger(UserEvent::EVENT_BEFORE_REGISTER, $event);
|
||||
$this->trigger(FormEvent::EVENT_BEFORE_REGISTER, $event);
|
||||
/** @var User $user */
|
||||
$user = $this->make(User::class, [], $form->attributes);
|
||||
$user->setScenario('register');
|
||||
@ -113,7 +113,7 @@ class RegistrationController extends Controller
|
||||
'Your account has been created and a message with further instructions has been sent to your email'
|
||||
)
|
||||
);
|
||||
$this->trigger(UserEvent::EVENT_AFTER_REGISTER, $event);
|
||||
$this->trigger(FormEvent::EVENT_AFTER_REGISTER, $event);
|
||||
|
||||
return $this->render(
|
||||
'/shared/message',
|
||||
|
||||
@ -22,6 +22,8 @@ class FormEvent extends Event
|
||||
const EVENT_AFTER_RESEND = 'afterResend';
|
||||
const EVENT_BEFORE_LOGIN = 'beforeLogin';
|
||||
const EVENT_AFTER_LOGIN = 'afterLogin';
|
||||
const EVENT_BEFORE_REGISTER = 'beforeRegister';
|
||||
const EVENT_AFTER_REGISTER = 'afterRegister';
|
||||
|
||||
protected $form;
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ use Da\User\Event\UserEvent;
|
||||
use Da\User\Factory\TokenFactory;
|
||||
use Da\User\Helper\SecurityHelper;
|
||||
use Da\User\Model\User;
|
||||
use Da\User\Traits\ContainerAwareTrait;
|
||||
use Da\User\Traits\ModuleAwareTrait;
|
||||
use Exception;
|
||||
use yii\base\InvalidCallException;
|
||||
@ -24,6 +25,7 @@ use yii\log\Logger;
|
||||
class UserRegisterService implements ServiceInterface
|
||||
{
|
||||
use ModuleAwareTrait;
|
||||
use ContainerAwareTrait;
|
||||
|
||||
protected $model;
|
||||
protected $securityHelper;
|
||||
@ -54,7 +56,8 @@ class UserRegisterService implements ServiceInterface
|
||||
? $this->securityHelper->generatePassword(8)
|
||||
: $model->password;
|
||||
|
||||
$model->trigger(UserEvent::EVENT_BEFORE_REGISTER);
|
||||
$userEvent = $this->make(UserEvent::class, [$model]);
|
||||
$model->trigger(UserEvent::EVENT_BEFORE_REGISTER, $userEvent);
|
||||
|
||||
if (!$model->save()) {
|
||||
$transaction->rollBack();
|
||||
@ -71,7 +74,7 @@ class UserRegisterService implements ServiceInterface
|
||||
}
|
||||
$this->mailService->run();
|
||||
|
||||
$model->trigger(UserEvent::EVENT_AFTER_REGISTER);
|
||||
$model->trigger(UserEvent::EVENT_AFTER_REGISTER, $userEvent);
|
||||
|
||||
$transaction->commit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user