@ -1,4 +1,7 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
- Fix #347: Only pass fields known to User model in registrationControl->actionRegister() (BillHeaton)
|
||||||
|
- Fix #346: Update ReCaptcha guide to not use AJAX (BillHeaton)
|
||||||
|
- Fix #345: Update ReCaptcha guide to add scenarios() in recoveryForm (BillHeaton)
|
||||||
- Fix #307: Fix French translation (arollmann)
|
- Fix #307: Fix French translation (arollmann)
|
||||||
- Fix #316: Fix new response from Google OAuth Api (Julian-B90)
|
- Fix #316: Fix new response from Google OAuth Api (Julian-B90)
|
||||||
- Fix #321: Fix new response from LinkedIn OAuth Api (tonydspaniard)
|
- Fix #321: Fix new response from LinkedIn OAuth Api (tonydspaniard)
|
||||||
|
|||||||
@ -30,34 +30,47 @@ Once you have the API site key you will also be displayed a secret key. You have
|
|||||||
Override the Form
|
Override the Form
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
For the sake of the example, we are going to override the `Da\User\Form\RecoveryForm` class:
|
For the sake of the example, we are going to override the `Da\User\Form\RecoveryForm` class. Create a new file `RecoveryForm`
|
||||||
|
add it to @app/models/Forms/ and put the following in it:
|
||||||
|
|
||||||
```php
|
```
|
||||||
namespace app\forms;
|
<?php
|
||||||
|
namespace app\models\Forms;
|
||||||
|
|
||||||
|
use Da\User\Form\RecoveryForm as BaseForm;
|
||||||
|
|
||||||
|
class RecoveryForm extends BaseForm {
|
||||||
|
|
||||||
class RecoveryForm extends Da\User\Form\RecoveryForm {
|
|
||||||
|
|
||||||
public $captcha;
|
public $captcha;
|
||||||
|
|
||||||
public function rules() {
|
public function rules() {
|
||||||
|
|
||||||
$rules = parent::rules();
|
$rules = parent::rules();
|
||||||
|
|
||||||
$rules[] = [['captcha'], 'required'];
|
$rules[] = [['captcha'], 'required'];
|
||||||
$rules[] = [['captcha'], 'Da\User\Validator\ReCaptchaValidator'];
|
$rules[] = [['captcha'], 'Da\User\Validator\ReCaptchaValidator'];
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scenarios()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
self::SCENARIO_REQUEST => ['email', 'captcha'],
|
||||||
|
self::SCENARIO_RESET => ['password'],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Overriding the View
|
Overriding the View
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
Create a new file and name it `request.php` and add it in `@app/views/user/recovery`. Add the captcha widget to it:
|
Create a new file and name it `request.php` and add it in `@app/views/user/recovery`. Add the captcha widget to it:
|
||||||
|
|
||||||
```php
|
```
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
@ -83,14 +96,14 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
<?php $form = ActiveForm::begin(
|
<?php $form = ActiveForm::begin(
|
||||||
[
|
[
|
||||||
'id' => $model->formName(),
|
'id' => $model->formName(),
|
||||||
'enableAjaxValidation' => true,
|
'enableAjaxValidation' => false,
|
||||||
'enableClientValidation' => false,
|
'enableClientValidation' => false,
|
||||||
]
|
]
|
||||||
); ?>
|
); ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'email')->textInput(['autofocus' => true]) ?>
|
<?= $form->field($model, 'email')->textInput(['autofocus' => true]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'captcha')->widget(ReCaptchaWidget::className(), ['theme' => 'dark']) ?>
|
<?= $form->field($model, 'captcha')->widget(ReCaptchaWidget::className(), ['theme' => 'light']) ?>
|
||||||
|
|
||||||
<?= Html::submitButton(Yii::t('usuario', 'Continue'), ['class' => 'btn btn-primary btn-block']) ?><br>
|
<?= Html::submitButton(Yii::t('usuario', 'Continue'), ['class' => 'btn btn-primary btn-block']) ?><br>
|
||||||
|
|
||||||
@ -115,13 +128,8 @@ Finally, we have to configure the module and the application to ensure is using
|
|||||||
'user' => [
|
'user' => [
|
||||||
'class' => Da\User\Module::class,
|
'class' => Da\User\Module::class,
|
||||||
'classMap' => [
|
'classMap' => [
|
||||||
'RecoveryForm' => 'app\forms\RecoveryForm'
|
'RecoveryForm' => 'app\models\Forms\RecoveryForm'
|
||||||
],
|
],
|
||||||
'controllerMap' => [
|
|
||||||
'recovery' => [
|
|
||||||
'class' => '\app\controllers\RecoveryController'
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -136,7 +144,15 @@ Finally, we have to configure the module and the application to ensure is using
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Notes For Other Forms
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
The outward facing forms (i.e. forms that you don't need to login to use) also include `registrationForm`, `resendForm`.
|
||||||
|
|
||||||
|
- All three forms need `'enableAjaxValidation' => false` in the view override.
|
||||||
|
- `registrationForm` & `resendForm` do not need `scenarios()` in the form override.
|
||||||
|
- `registrationForm` needs fix #347 to work.
|
||||||
|
|
||||||
© [2amigos](http://www.2amigos.us/) 2013-2019
|
© [2amigos](http://www.2amigos.us/) 2013-2019
|
||||||
|
|||||||
@ -88,6 +88,9 @@ class RegistrationController extends Controller
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function actionRegister()
|
public function actionRegister()
|
||||||
{
|
{
|
||||||
if (!$this->module->enableRegistration) {
|
if (!$this->module->enableRegistration) {
|
||||||
@ -104,12 +107,18 @@ class RegistrationController extends Controller
|
|||||||
$this->trigger(FormEvent::EVENT_BEFORE_REGISTER, $event);
|
$this->trigger(FormEvent::EVENT_BEFORE_REGISTER, $event);
|
||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = $this->make(User::class, [],
|
|
||||||
[ 'email' => $form->attributes['email'],
|
|
||||||
'username' => $form->attributes['username'],
|
|
||||||
'password' => $form->attributes['password']
|
|
||||||
]); $user->setScenario('register');
|
|
||||||
|
|
||||||
|
// Create a temporay $user so we can get the attributes, then get
|
||||||
|
// the intersection between the $form fields and the $user fields.
|
||||||
|
$user = $this->make(User::class, [] );
|
||||||
|
$fields = array_intersect_key($form->attributes, $user->attributes);
|
||||||
|
|
||||||
|
// Becomes password_hash
|
||||||
|
$fields['password'] = $form['password'];
|
||||||
|
|
||||||
|
$user = $this->make(User::class, [], $fields );
|
||||||
|
|
||||||
|
$user->setScenario('register');
|
||||||
$mailService = MailFactory::makeWelcomeMailerService($user);
|
$mailService = MailFactory::makeWelcomeMailerService($user);
|
||||||
|
|
||||||
if ($this->make(UserRegisterService::class, [$user, $mailService])->run()) {
|
if ($this->make(UserRegisterService::class, [$user, $mailService])->run()) {
|
||||||
@ -138,6 +147,9 @@ class RegistrationController extends Controller
|
|||||||
return $this->render('register', ['model' => $form, 'module' => $this->module]);
|
return $this->render('register', ['model' => $form, 'module' => $this->module]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function actionConnect($code)
|
public function actionConnect($code)
|
||||||
{
|
{
|
||||||
/** @var SocialNetworkAccount $account */
|
/** @var SocialNetworkAccount $account */
|
||||||
@ -179,6 +191,9 @@ class RegistrationController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function actionConfirm($id, $code)
|
public function actionConfirm($id, $code)
|
||||||
{
|
{
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
@ -215,6 +230,9 @@ class RegistrationController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function actionResend()
|
public function actionResend()
|
||||||
{
|
{
|
||||||
if ($this->module->enableEmailConfirmation === false) {
|
if ($this->module->enableEmailConfirmation === false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user