Close #55 add google captcha mechanism
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
## 1.0.14 - Work in progress
|
## 1.0.14 - Work in progress
|
||||||
|
- Enh #55: Provide google recaptcha mechanism (tonydspaniard)
|
||||||
- Fix #20: Allow the assignment of a role on user creation via console (tonydspaniard)
|
- Fix #20: Allow the assignment of a role on user creation via console (tonydspaniard)
|
||||||
- Fix #59: Add instructions to add rbac migration path (tonydspaniard)
|
- Fix #59: Add instructions to add rbac migration path (tonydspaniard)
|
||||||
- Fix #68: Fix user events documentation and events raised from User model (tonydspaniard)
|
- Fix #68: Fix user events documentation and events raised from User model (tonydspaniard)
|
||||||
|
|||||||
@ -49,6 +49,7 @@
|
|||||||
"php": ">=5.5",
|
"php": ">=5.5",
|
||||||
"2amigos/yii2-selectize-widget": "^1.1",
|
"2amigos/yii2-selectize-widget": "^1.1",
|
||||||
"yiisoft/yii2-authclient": "^2.1",
|
"yiisoft/yii2-authclient": "^2.1",
|
||||||
|
"yiisoft/yii2-httpclient": "^2.0",
|
||||||
"yiisoft/yii2-bootstrap": "^2.0",
|
"yiisoft/yii2-bootstrap": "^2.0",
|
||||||
"yiisoft/yii2-swiftmailer": "^2.0",
|
"yiisoft/yii2-swiftmailer": "^2.0",
|
||||||
"2amigos/2fa-library": "^1.0",
|
"2amigos/2fa-library": "^1.0",
|
||||||
|
|||||||
142
docs/helpful-guides/how-to-use-recaptcha-widget.md
Normal file
142
docs/helpful-guides/how-to-use-recaptcha-widget.md
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
How to Use ReCaptcha Widget
|
||||||
|
============================
|
||||||
|
|
||||||
|
We have included a [Google ReCAPTCHA](https://developers.google.com/recaptcha) widget if you wish to use it instead of
|
||||||
|
Yii's captcha. The widget is based on reCaptcha v2.0.
|
||||||
|
|
||||||
|
To make use of the widget you need to:
|
||||||
|
|
||||||
|
- [Signup for a reCaptcha API site key](https://www.google.com/recaptcha/admin#createsite)
|
||||||
|
- Configure the `ReCaptchaComponent` on the `components` section of your application configuration
|
||||||
|
- Override the Form class you wish to add the captcha rule to
|
||||||
|
- Override the view where the form is rendering
|
||||||
|
- Configure Module and Application
|
||||||
|
|
||||||
|
Configuring the ReCaptchaComponent
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Once you have the API site key you will also be displayed a secret key. You have to configure the component as follows:
|
||||||
|
|
||||||
|
```php
|
||||||
|
'components' => [
|
||||||
|
'recaptcha' => [ // *important* this name must be like this
|
||||||
|
'class' => 'Da\User\Component\ReCaptchaComponent',
|
||||||
|
'key' => 'yourSiteKey',
|
||||||
|
'secret' => 'secretKeyGivenByGoogle
|
||||||
|
]
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Override the Form
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
For the sake of the example, we are going to override the `Da\User\Form\RecoveryForm` class:
|
||||||
|
|
||||||
|
```php
|
||||||
|
namespace app\forms;
|
||||||
|
|
||||||
|
class RecoveryForm extends Da\User\Form\RecoveryForm {
|
||||||
|
|
||||||
|
public $captcha;
|
||||||
|
|
||||||
|
public function rules() {
|
||||||
|
|
||||||
|
$rules = parent::rules();
|
||||||
|
|
||||||
|
$rules[] = [['captcha'], 'required'];
|
||||||
|
$rules[] = [['captcha'], 'Da\User\Validator\ReCaptchaValidator'];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use Da\User\Widget\ReCaptchaWidget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var yii\web\View $this
|
||||||
|
* @var yii\widgets\ActiveForm $form
|
||||||
|
* @var \Da\User\Form\RecoveryForm $model
|
||||||
|
*/
|
||||||
|
|
||||||
|
$this->title = Yii::t('usuario', 'Recover your password');
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title"><?= Html::encode($this->title) ?></h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<?php $form = ActiveForm::begin(
|
||||||
|
[
|
||||||
|
'id' => $model->formName(),
|
||||||
|
'enableAjaxValidation' => true,
|
||||||
|
'enableClientValidation' => false,
|
||||||
|
]
|
||||||
|
); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'email')->textInput(['autofocus' => true]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'captcha')->widget(ReCaptchaWidget::className(), ['theme' => 'dark']) ?>
|
||||||
|
|
||||||
|
<?= Html::submitButton(Yii::t('usuario', 'Continue'), ['class' => 'btn btn-primary btn-block']) ?><br>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Configure Module and Application
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
Finally, we have to configure the module and the application to ensure is using our form and our view:
|
||||||
|
|
||||||
|
```php
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
'modules' => [
|
||||||
|
'user' => [
|
||||||
|
'class' => Da\User\Module::class,
|
||||||
|
'classMap' => [
|
||||||
|
'RecoveryForm' => 'app\forms\RecoveryForm'
|
||||||
|
],
|
||||||
|
'controllerMap' => [
|
||||||
|
'recovery' => [
|
||||||
|
'class' => '\app\controllers\RecoveryController'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
'components' => [
|
||||||
|
'view' => [
|
||||||
|
'theme' => [
|
||||||
|
'pathMap' => [
|
||||||
|
'@Da/User/resources/views' => '@app/views/user'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
© [2amigos](http://www.2amigos.us/) 2013-2017
|
||||||
@ -39,7 +39,6 @@ class CreateController extends Controller
|
|||||||
if (null !== $role) {
|
if (null !== $role) {
|
||||||
$this->assignRole($user, $role);
|
$this->assignRole($user, $role);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->stdout(Yii::t('usuario', 'Please fix following errors:') . "\n", Console::FG_RED);
|
$this->stdout(Yii::t('usuario', 'Please fix following errors:') . "\n", Console::FG_RED);
|
||||||
foreach ($user->errors as $errors) {
|
foreach ($user->errors as $errors) {
|
||||||
|
|||||||
75
src/User/Component/ReCaptchaComponent.php
Normal file
75
src/User/Component/ReCaptchaComponent.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
|
*
|
||||||
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Da\User\Component;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Component;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
use yii\httpclient\Client;
|
||||||
|
|
||||||
|
class ReCaptchaComponent extends Component
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string the ReCAPTCHA sitekey
|
||||||
|
*/
|
||||||
|
public $key;
|
||||||
|
/**
|
||||||
|
* @var string the shared key between the site and ReCAPTCHA
|
||||||
|
*/
|
||||||
|
public $secret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
if (empty($this->key)) {
|
||||||
|
throw new InvalidConfigException(Yii::t('usuario', 'Required "key" cannot be empty.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->secret)) {
|
||||||
|
throw new InvalidConfigException(Yii::t('usuario', 'Required "secret" cannot be empty.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies whether a user response is valid or not.
|
||||||
|
*
|
||||||
|
* @param $value
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function verify($value)
|
||||||
|
{
|
||||||
|
$response = (new Client(
|
||||||
|
[
|
||||||
|
'baseUrl' => 'https://www.google.com/recaptcha/api',
|
||||||
|
'responseConfig' => [
|
||||||
|
'format' => Client::FORMAT_JSON
|
||||||
|
]
|
||||||
|
]
|
||||||
|
))
|
||||||
|
->get(
|
||||||
|
'site/verify',
|
||||||
|
[
|
||||||
|
'secret' => $this->secret,
|
||||||
|
'response' => $value,
|
||||||
|
'remoteip' => Yii::$app->request->getUserIP()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return $response['success'] ? : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -156,10 +156,9 @@ class RecoveryController extends Controller
|
|||||||
|
|
||||||
if ($form->load(Yii::$app->getRequest()->post())) {
|
if ($form->load(Yii::$app->getRequest()->post())) {
|
||||||
if ($this->make(ResetPasswordService::class, [$form->password, $token->user])->run()) {
|
if ($this->make(ResetPasswordService::class, [$form->password, $token->user])->run()) {
|
||||||
|
|
||||||
$this->trigger(ResetPasswordEvent::EVENT_AFTER_RESET, $event);
|
$this->trigger(ResetPasswordEvent::EVENT_AFTER_RESET, $event);
|
||||||
|
|
||||||
Yii::$app->session->setFlash('success',Yii::t('usuario', 'Password has been changed'));
|
Yii::$app->session->setFlash('success', Yii::t('usuario', 'Password has been changed'));
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'/shared/message',
|
'/shared/message',
|
||||||
|
|||||||
@ -37,10 +37,10 @@ class SecurityController extends Controller
|
|||||||
/**
|
/**
|
||||||
* SecurityController constructor.
|
* SecurityController constructor.
|
||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param Module $module
|
* @param Module $module
|
||||||
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
|
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$id,
|
$id,
|
||||||
@ -117,14 +117,12 @@ class SecurityController extends Controller
|
|||||||
$event = $this->make(FormEvent::class, [$form]);
|
$event = $this->make(FormEvent::class, [$form]);
|
||||||
|
|
||||||
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
|
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
|
||||||
|
|
||||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
return ActiveForm::validate($form);
|
return ActiveForm::validate($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($form->load(Yii::$app->request->post())) {
|
if ($form->load(Yii::$app->request->post())) {
|
||||||
|
|
||||||
if ($this->module->enableTwoFactorAuthentication && $form->validate()) {
|
if ($this->module->enableTwoFactorAuthentication && $form->validate()) {
|
||||||
if ($form->getUser()->auth_tf_enabled) {
|
if ($form->getUser()->auth_tf_enabled) {
|
||||||
Yii::$app->session->set('credentials', ['login' => $form->login, 'pwd' => $form->password]);
|
Yii::$app->session->set('credentials', ['login' => $form->login, 'pwd' => $form->password]);
|
||||||
@ -173,18 +171,15 @@ class SecurityController extends Controller
|
|||||||
$event = $this->make(FormEvent::class, [$form]);
|
$event = $this->make(FormEvent::class, [$form]);
|
||||||
|
|
||||||
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
|
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
|
||||||
|
|
||||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
return ActiveForm::validate($form);
|
return ActiveForm::validate($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($form->load(Yii::$app->request->post())) {
|
if ($form->load(Yii::$app->request->post())) {
|
||||||
|
|
||||||
$this->trigger(FormEvent::EVENT_BEFORE_LOGIN, $event);
|
$this->trigger(FormEvent::EVENT_BEFORE_LOGIN, $event);
|
||||||
|
|
||||||
if ($form->login()) {
|
if ($form->login()) {
|
||||||
|
|
||||||
Yii::$app->session->set('credentials', null);
|
Yii::$app->session->set('credentials', null);
|
||||||
|
|
||||||
$form->getUser()->updateAttributes(['last_login_at' => time()]);
|
$form->getUser()->updateAttributes(['last_login_at' => time()]);
|
||||||
@ -202,7 +197,6 @@ class SecurityController extends Controller
|
|||||||
'module' => $this->module,
|
'module' => $this->module,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionLogout()
|
public function actionLogout()
|
||||||
|
|||||||
@ -52,12 +52,12 @@ class SettingsController extends Controller
|
|||||||
/**
|
/**
|
||||||
* SettingsController constructor.
|
* SettingsController constructor.
|
||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param Module $module
|
* @param Module $module
|
||||||
* @param ProfileQuery $profileQuery
|
* @param ProfileQuery $profileQuery
|
||||||
* @param UserQuery $userQuery
|
* @param UserQuery $userQuery
|
||||||
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
|
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$id,
|
$id,
|
||||||
@ -294,8 +294,7 @@ class SettingsController extends Controller
|
|||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($user->updateAttributes(['auth_tf_enabled' => '0']))
|
if ($user->updateAttributes(['auth_tf_enabled' => '0'])) {
|
||||||
{
|
|
||||||
Yii::$app
|
Yii::$app
|
||||||
->getSession()
|
->getSession()
|
||||||
->setFlash('success', Yii::t('usuario', 'Two-factor authorization has been disabled.'));
|
->setFlash('success', Yii::t('usuario', 'Two-factor authorization has been disabled.'));
|
||||||
|
|||||||
@ -53,9 +53,9 @@ class LoginForm extends Model
|
|||||||
protected $securityHelper;
|
protected $securityHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserQuery $query
|
* @param UserQuery $query
|
||||||
* @param SecurityHelper $securityHelper
|
* @param SecurityHelper $securityHelper
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
public function __construct(UserQuery $query, SecurityHelper $securityHelper, $config = [])
|
public function __construct(UserQuery $query, SecurityHelper $securityHelper, $config = [])
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
|
*
|
||||||
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Da\User\Helper;
|
namespace Da\User\Helper;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
|
*
|
||||||
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Da\User\Service;
|
namespace Da\User\Service;
|
||||||
|
|
||||||
use Da\TwoFA\Manager;
|
use Da\TwoFA\Manager;
|
||||||
@ -42,5 +51,4 @@ class TwoFactorQrCodeUriGeneratorService implements ServiceInterface
|
|||||||
|
|
||||||
return $dataUri;
|
return $dataUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
68
src/User/Validator/ReCaptchaValidator.php
Normal file
68
src/User/Validator/ReCaptchaValidator.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
|
*
|
||||||
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Da\User\Validator;
|
||||||
|
|
||||||
|
use Da\User\Component\ReCaptchaComponent;
|
||||||
|
use Yii;
|
||||||
|
use yii\validators\Validator;
|
||||||
|
|
||||||
|
class ReCaptchaValidator extends Validator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public $skipOnEmpty = false;
|
||||||
|
/**
|
||||||
|
* @var string the message for client validation
|
||||||
|
*/
|
||||||
|
public $notCheckedMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
|
||||||
|
if (null === $this->message) {
|
||||||
|
$this->message = Yii::t('usuario', 'The verification code is incorrect.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function clientValidateAttribute($model, $attribute, $view)
|
||||||
|
{
|
||||||
|
$message = addslashes(
|
||||||
|
$this->notCheckedMessage ?: Yii::t('usuario', '{0} cannot be blank.', $model->getAttributeLabel($attribute))
|
||||||
|
);
|
||||||
|
|
||||||
|
return "(function(messages){if(!grecaptcha.getResponse()){messages.push('{$message}');}})(messages);";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
protected function validateValue($value)
|
||||||
|
{
|
||||||
|
if (empty($value)) {
|
||||||
|
if (!($value = Yii::$app->request->post('g-recaptcha-response'))) {
|
||||||
|
return [$this->message, []];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** @var ReCaptchaComponent $recaptcha */
|
||||||
|
$recaptcha = Yii::$app->get('recaptcha');
|
||||||
|
|
||||||
|
return $recaptcha->verify($value) ? null : [$this->message, []];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
|
*
|
||||||
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Da\User\Validator;
|
namespace Da\User\Validator;
|
||||||
|
|
||||||
use Da\TwoFA\Manager;
|
use Da\TwoFA\Manager;
|
||||||
|
|||||||
163
src/User/Widget/ReCaptchaWidget.php
Normal file
163
src/User/Widget/ReCaptchaWidget.php
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
|
*
|
||||||
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Da\User\Widget;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\web\View;
|
||||||
|
use yii\widgets\InputWidget;
|
||||||
|
|
||||||
|
class ReCaptchaWidget extends InputWidget
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string the color theme of the widget. Values can be 'dark' or 'light'. Optional.
|
||||||
|
*/
|
||||||
|
public $theme;
|
||||||
|
/**
|
||||||
|
* @var string the type of captcha. Values can be 'audio' or 'image'. Optional.
|
||||||
|
*/
|
||||||
|
public $type;
|
||||||
|
/**
|
||||||
|
* @var string the size of the widget. Values can be 'compact' or 'normal'. Optional.
|
||||||
|
*/
|
||||||
|
public $size;
|
||||||
|
/**
|
||||||
|
* @var string the tabindex of the widget and challenge. Optional.
|
||||||
|
*/
|
||||||
|
public $tabIndex;
|
||||||
|
/**
|
||||||
|
* @var string the name of the callbaqck function to be executed when the user submits a
|
||||||
|
* successful CAPTCHA response. The user's response, *g-recaptcha-response*, will be the input
|
||||||
|
* for the callback function. Optional.
|
||||||
|
*/
|
||||||
|
public $callback;
|
||||||
|
/**
|
||||||
|
* @var string the name of the callback function to be executed when the recaptcha response
|
||||||
|
* expires and the user needs to solve a new CAPTCHA.
|
||||||
|
*/
|
||||||
|
public $expiredCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
if (Yii::$app->get('recaptcha')) {
|
||||||
|
throw new InvalidConfigException(Yii::t('usuario', 'The "recaptcha" component must be configured.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::init();
|
||||||
|
|
||||||
|
$this->registerClientScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$html = [];
|
||||||
|
|
||||||
|
$html[] = $this->hasModel()
|
||||||
|
? Html::activeHiddenInput($this->model, $this->attribute, $this->options)
|
||||||
|
: Html::hiddenInput($this->name, null, $this->options);
|
||||||
|
|
||||||
|
$html[] = Html::tag('div', '', $this->getCaptchaOptions());
|
||||||
|
|
||||||
|
return implode("\n", $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array the google recaptcha options.
|
||||||
|
*/
|
||||||
|
protected function getCaptchaOptions()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'sitekey' => Yii::$app->get('recaptcha')->key,
|
||||||
|
'callback' => $this->callback,
|
||||||
|
'expired-callback' => $this->expiredCallback,
|
||||||
|
'theme' => $this->theme,
|
||||||
|
'type' => $this->type,
|
||||||
|
'size' => $this->size,
|
||||||
|
'tabindex' => $this->tabIndex
|
||||||
|
];
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
'class' => 'g-recaptcha',
|
||||||
|
'data' => array_filter($data)
|
||||||
|
];
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the required libraries and scripts for the widget to work.
|
||||||
|
*/
|
||||||
|
protected function registerClientScript()
|
||||||
|
{
|
||||||
|
$view = $this->getView();
|
||||||
|
|
||||||
|
$view->registerJsFile(
|
||||||
|
'//www.google.com/recaptcha/api.js?hl=' . $this->getLanguageCode(),
|
||||||
|
[
|
||||||
|
'position' => View::POS_HEAD,
|
||||||
|
'async' => true,
|
||||||
|
'defer' => true
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$js = [];
|
||||||
|
$id = $this->options['id'];
|
||||||
|
|
||||||
|
$js[] = empty($this->callback)
|
||||||
|
? "var reCaptchaCallback = function(r){jQuery('#{$id}').val(r);};"
|
||||||
|
: "var reCaptchaCallback = function(r){jQuery('#{$id}').val(r); {$this->callback}(r);};";
|
||||||
|
|
||||||
|
$this->callback = 'reCaptchaCallback';
|
||||||
|
|
||||||
|
$js[] = empty($this->expiredCallback)
|
||||||
|
? "var reCaptchaExpiredCallback = function(){jQuery('#{$id}').val('');};"
|
||||||
|
: "var reCaptchaExpiredCallback = function(){jQuery('#{$id}').val(''); {$this->expiredCallback}();};";
|
||||||
|
|
||||||
|
$this->expiredCallback = 'reCaptchaExpiredCallback';
|
||||||
|
|
||||||
|
$view->registerJs(implode("\n", $js), View::POS_BEGIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool|string the language code config option for google recatpcha library url.
|
||||||
|
*/
|
||||||
|
protected function getLanguageCode()
|
||||||
|
{
|
||||||
|
$language = Yii::$app->language;
|
||||||
|
|
||||||
|
if (strpos($language, '-') === false) {
|
||||||
|
return $language;
|
||||||
|
}
|
||||||
|
|
||||||
|
$except = [
|
||||||
|
'zh-HK',
|
||||||
|
'zh-CN',
|
||||||
|
'zh-TW',
|
||||||
|
'en-GB',
|
||||||
|
'de-AT',
|
||||||
|
'de-CH',
|
||||||
|
'pt-BR',
|
||||||
|
'pt-PT'
|
||||||
|
];
|
||||||
|
|
||||||
|
return in_array($language, $except)
|
||||||
|
? $language
|
||||||
|
: substr($language, 0, strpos($language, '-'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
||||||
'Are you sure you want to switch to this user for the rest of this Session?' => '',
|
'Are you sure you want to switch to this user for the rest of this Session?' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'Cannot assign role "{0}" as the AuthManager is not configured on your console application.' => 'No se puede asignar rol "{0}" ya que AuthManager no ha sido configurado en tu aplicación de consola.',
|
'Cannot assign role "{0}" as the AuthManager is not configured on your console application.' => 'No se puede asignar rol "{0}" ya que AuthManager no ha sido configurado en tu aplicación de consola.',
|
||||||
'Role "{0}" not found. Creating it.' => 'Rol "{0}" no encontrado. Creándolo.',
|
'Role "{0}" not found. Creating it.' => 'Rol "{0}" no encontrado. Creándolo.',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
||||||
'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '',
|
'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
||||||
'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '',
|
'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'Cannot assign role "{0}" as the AuthManager is not configured on your console application.' => '',
|
'Cannot assign role "{0}" as the AuthManager is not configured on your console application.' => '',
|
||||||
'Role "{0}" not found. Creating it.' => '',
|
'Role "{0}" not found. Creating it.' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
||||||
'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '',
|
'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
|
||||||
'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '',
|
'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -1,21 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Message translations.
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* This file is automatically generated by 'yii message/extract' command.
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
* It contains the localizable messages extracted from source code.
|
|
||||||
* You may modify this file by translating the extracted messages.
|
|
||||||
*
|
*
|
||||||
* Each array element represents the translation (value) of a message (key).
|
* For the full copyright and license information, please view
|
||||||
* If the value is empty, the message is considered as not translated.
|
* the LICENSE file that was distributed with this source code.
|
||||||
* Messages that no longer need translation will have their translations
|
|
||||||
* enclosed between a pair of '@@' marks.
|
|
||||||
*
|
|
||||||
* Message string can be used with plural forms format. Check i18n section
|
|
||||||
* of the guide for details.
|
|
||||||
*
|
|
||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'(not set)' => '',
|
'(not set)' => '',
|
||||||
'A confirmation message has been sent to your new email address' => '',
|
'A confirmation message has been sent to your new email address' => '',
|
||||||
|
|||||||
@ -63,7 +63,7 @@ $module = Yii::$app->getModule('user');
|
|||||||
'value' => function ($model) {
|
'value' => function ($model) {
|
||||||
if (!$model->last_login_at || $model->last_login_at == 0) {
|
if (!$model->last_login_at || $model->last_login_at == 0) {
|
||||||
return Yii::t('usuario', 'Never');
|
return Yii::t('usuario', 'Never');
|
||||||
} else if (extension_loaded('intl')) {
|
} elseif (extension_loaded('intl')) {
|
||||||
return Yii::t('usuario', '{0, date, MMMM dd, YYYY HH:mm}', [$model->last_login_at]);
|
return Yii::t('usuario', '{0, date, MMMM dd, YYYY HH:mm}', [$model->last_login_at]);
|
||||||
} else {
|
} else {
|
||||||
return date('Y-m-d G:i:s', $model->last_login_at);
|
return date('Y-m-d G:i:s', $model->last_login_at);
|
||||||
|
|||||||
@ -14,8 +14,8 @@ use yii\helpers\Url;
|
|||||||
use yii\widgets\ActiveForm;
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var yii\web\View $this
|
* @var yii\web\View $this
|
||||||
* @var yii\widgets\ActiveForm $form
|
* @var yii\widgets\ActiveForm $form
|
||||||
* @var \Da\User\Form\SettingsForm $model
|
* @var \Da\User\Form\SettingsForm $model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user