Highly customizable and extensible user management, authentication, and authorization Yii2 extension
tonydspaniard on master
Add nl_NL Dutch translation. Mi… Improve translations Merge pull request #301 from sq… (compare)
maxxer on master
Fix password expire service #293 (compare)
Another comment about the instructions: The second migration, yii migrate --migrationPath=@yii/rbac/migrations, won't work unless the authManager has been configured. Could you add that to the Components section of the example in Step 2? This would help people who aren't familiar with RBAC and haven't configured Dektrium before.
About my previous comment where I mentioned the User table and failing the first migration. My apologies, I see now you have a note to not install the Advanced Template migration m130524_201442_init.php. However, if a user has already completed the Advanced Template setup, they will have already done this migration. Perhaps you could place a note above the mention of the Advanced Template to warn users not to perform the migrations as the Advanced Template instructions state, and if they have done so, to drop the table?
Again, thanks for listening.
'confirm' => [
'on ' . Da\User\Event\UserEvent::EVENT_AFTER_CONFIRMATION => function (Da\User\Event\UserEvent $event) {
Yii::$app->controller->redirect(['/user/settings/profile']);
Yii::$app->end();
}
],
],
redirect
must be called with return
Hello
I'm trying to use the recaptcha widget on the RegistrationForm just like I did on RecoveryForm, by following the website's guide. Everything is working fine except that, on the register form, I can't validate the captcha because it keeps saying "Captcha cannot be blank" due to the "required" rule shown in the image above.
Now, this doesn't happen on the Recovery form where I too have the "required" rule just like that. I can take the rule out of the code, but I wanted to keep it just like I can in the recovery form.
What am I missing? Is the RegistrationForm just different from the RecoveryForm and I should just remove the rule?
Thanks
Pls, help me. The problem with authorization through social network new user. Return 404 /user/registration/connect?code=FMwHPLCI*DJC
// Da\User\Controller\RegistrationController
public function actionConnect($code)
{
/** @var SocialNetworkAccount $account */
$account = $this->socialNetworkAccountQuery->whereCode($code)->one();
if ($account === null || $account->getIsConnected()) {
throw new NotFoundHttpException(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! social_account not saved
}
...
}
// Da\User\Service\SocialNetworkAuthenticateService
protected function createAccount()
{
$data = $this->client->getUserAttributes();
/** @var SocialNetworkAccount $account */
$account = $this->controller->make(
SocialNetworkAccount::class,
[],
[
'provider' => $this->client->getId(),
'client_id' => $data['id'],
'data' => json_encode($data),
'username' => $this->client->getUserName(),
'email' => $this->client->getEmail(),
]
);
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! User not found => social_account not save
if (($user = $this->getUser($account)) instanceof User) {
$account->user_id = $user->id;
$account->save(false);
}
return $account;
}
I tried all events. The problem is solved only this way, otherwise redirecting to 404
'security' => [
'class' => 'Da\User\Controller\SecurityController',
'layout' => '@app/views/layouts/main_with_container',
// beforeAuthenticate
// afterAuthenticate
// beforeConnect
// afterConnect
'on beforeAuthenticate' => function($event){
/** @var Da\User\Event\SocialNetworkAuthEvent $event */
/** @var Da\User\Model\User $user */
if(Da\User\Model\User::find()->where(['email' => $event->client->email])->exists()) return;
$user = Yii::createObject([
'class' => Da\User\Model\User::class,
'scenario' => 'create',
'email' => $event->client->email,
'username' => $event->client->username,
'password' => null
]);
$mailService = \Da\User\Factory\MailFactory::makeWelcomeMailerService($user);
$userCreateService = Yii::createObject([
'class' => \Da\User\Service\UserCreateService::class,
], [$user, $mailService]);
$userCreateService->run();
$event->account->user_id = $user->id;
$event->account->save();
Yii::$app->user->login($user);
}
],
Hello. I am trying to install the Usuario module in a fresh Yii2 Advanced Template instance. I have the baseline instance working (frontend and backend), but when I attempt to apply the migrations according to your instructions [here|https://yii2-usuario.readthedocs.io/en/latest/installation/advanced-application-template/] I get an error:
yii-adv-app>> php yii migrate
Yii Migration Tool (based on Yii v2.0.39.2)
Exception 'yii\base\InvalidArgumentException' with message 'Invalid path alias: @Da/User/Migration'
in /Users/xxxxxx/PhpstormProjects/wwwrootYii2Portals/yii-adv-app/vendor/yiisoft/yii2/BaseYii.php:154
Stack trace:
#0 /Users/xxxxxx/PhpstormProjects/wwwrootYii2Portals/yii-adv-app/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(710): yii\BaseYii::getAlias('@Da/User/Migrat...')
#1 /Users/xxxxxx/PhpstormProjects/wwwrootYii2Portals/yii-adv-app/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(890): yii\console\controllers\BaseMigrateController->getNamespacePath('Da\User\Migrati...')
Is there any reason why the Usuario code would generate this error? I'm at a loss why this is happening.
I see now what happened. The instructions show two methods for performing the migrations: the first method is from the command line, and the second requires modification of the console->config->main.php, specifically, adding a controllerMap configuration with a definition for migrationNamespace pointing to Da\User\Migration.
When the first method didn't work, I tried the second, but the instructions don't tell you what to do after making the changes to the configuration file. So I went back to the first method but forgot to remove my controllerMap changes to the console config file.
Once I removed the controllerMap settings from console->config->main.php, I was able to run the migration from the command line without the invalidArgumentException.