Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jan 23 2019 21:39
    WhatTheBuild starred 2amigos/yii2-usuario
  • Jan 21 2019 15:22
    qav-gabriela-castro starred 2amigos/yii2-usuario
  • Jan 17 2019 14:14
    ljfreelancer88 starred 2amigos/yii2-usuario
  • Jan 17 2019 07:40
    tsdogs opened #302
  • Jan 15 2019 15:59

    tonydspaniard on master

    Add nl_NL Dutch translation. Mi… Improve translations Merge pull request #301 from sq… (compare)

  • Jan 15 2019 15:59
    tonydspaniard closed #301
  • Jan 15 2019 15:57
    tonydspaniard commented #301
  • Jan 15 2019 15:05
    squio synchronize #301
  • Jan 15 2019 10:17
    squio opened #301
  • Jan 04 2019 13:40
    maxxer commented #298
  • Jan 04 2019 13:20
    theonedemon starred 2amigos/yii2-usuario
  • Jan 04 2019 12:50
    schmunk42 opened #298
  • Dec 31 2018 10:31
    maxxer closed #293
  • Dec 31 2018 10:31
    maxxer commented #293
  • Dec 31 2018 10:30

    maxxer on master

    Fix password expire service #293 (compare)

  • Dec 19 2018 15:34
    steelice starred 2amigos/yii2-usuario
  • Dec 19 2018 10:22
    tonydspaniard commented #289
  • Dec 19 2018 07:47
    bscheshirwork commented #289
  • Dec 18 2018 21:01
  • Dec 12 2018 16:35
    maxxer commented #289
John Goetz

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.

John Goetz
Hello, has anyone successfully installed Yii2-usuario on the Advanced Template? We are running into problems that seem well beyond average. Any hints?
but is this project still to be considered alive?
It seems interesting but I met a lot of problems during its implementation...
Amit Arya
has anyone managed to change mail template contents after registration?
Pedro Luis Rodríguez Amador
how to generate admin full control role and permission ?
but is this project still to be considered alive?
Hey guys, any guide of how to add profile field(s) to registration form? Dektrium way doesn't work.
Guys, any possibility we are getting help with issue #124 ? 2amigos/yii2-usuario#124
...here I read messages, but someone can tell me if the project is usable or not? thanks
John Goetz
My colleague was finally able to get things working.
I don't see any responses from the maintainers; my guess is they aren't actively working on it any more.
It would be nice to have a small answer from them, or someone who went on with a fork this project.
Thiago Otaviani Vidal
hey guys
anyone online?
All online but for what?!
Thiago Otaviani Vidal
lol. sorry. never used gitter.
This amazing repo... Is dead!! Sigh
Amit Arya
Stefan Jacomeit
Hey, how can I use the extension to use jwt token for API calls?
Ron Jenkins
Anyone online?
I'm setting up 2amigos/yii2-usuario in the yii2 basic template, and I'm very close to having it working, but I'm missing something small :)
is there is any tutorial how to use the module?
@RonJenk99469709_twitter share please how?
@RonJenk99469709_twitter How what?
Benjamín Rivero
Hi all, I recently setup this extension and works great. What problem do you have @RonJenk99469709_twitter
How can get the user logged ?
does not work redirect after confirm user. Overriding model
'controllerMap' => [
    'confirm' => [
        'on ' . Da\User\Event\UserEvent::EVENT_AFTER_CONFIRMATION => function (Da\User\Event\UserEvent $event) {
I'm about to switch from dectrium user to Usuario.
My user has a role "admin".
Nevertheless I have no access to /user/admin.
If I replace 'admin' in the AdminController with any other role it works strangely.
Any idea where the problem is?
@maxxer Any idea?
Hi, I have installed the yii2 application as per your package with usuario and config kit
But it still seems to want to use the standard user model and not usuario
Lorenzo Milesi
@paskuale75 not really dead, come on :)
@virbus redirect must be called with return

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?


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(
                '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;

        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]);


                        $event->account->user_id = $user->id;

John Goetz

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.

John Goetz

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.

John Goetz

So, I removed the controllerMap settings and tried the command line version again.

I'm still getting the Invalid path alias from the first command:
yii-adv-app/> php yii migrate --migrationNamespaces=Da\User\Migration;
Yii Migration Tool (based on Yii v2.0.39.2)

Exception 'yii\base\InvalidArgumentException' with message 'Invalid path alias: @Da/User/Migration'

in /Users/jgoetz/PhpstormProjects/wwwrootYii2Portals/yii-adv-app/vendor/yiisoft/yii2/BaseYii.php:154

Stack trace:

#0 /Users/jgoetz/PhpstormProjects/wwwrootYii2Portals/yii-adv-app/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(710): yii\BaseYii::getAlias('@Da/User/Migrat...')

#1 /Users/jgoetz/PhpstormProjects/wwwrootYii2Portals/yii-adv-app/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(890): yii\console\controllers\BaseMigrateController->getNamespacePath('Da\User\Migrati...')

John Goetz

To correct the invalid path alias error, I added an alias in common->config->main.php:

return [
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
@Da' => '@vendor/2amigos/yii2-usuario/src'
'vendorPath' => dirname(dirname(DIR)) . '/vendor',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',

John Goetz
Has anyone successfully integrated yii2-usuario into the Advanced Template? I'd love to see a working example. All the instructions seem to be for the Basic Template.
I tried it a few months ago but I lost hope, and I am amazed that there is still someone who tries to use it, in my opinion this repository has been dead for quite a while, too bad because it looked promising...
John Goetz
Thanks, @paskuale75 . I'm just about hopeless myself. I can't get Usuario to work on the Basic Template, the Advanced Template, or the ConfigKit Application. Is it just me? Has anyone been able to get this working on any platform/Application?
if you don't find alternatives I'm finally using this https://github.com/sjaakp/yii2-pluto
John Goetz
Thanks, @paskuale75. It looks like you and your team have done a great job! Unfortunately, I have to have the Dektrium-based tables, so your solution doesn't look like it will work for me. Good luck!
Negruzzi Cristian
@jgoetz recently i've integrated yii2-usuario in 3 projects with Advanced Template, nothing special, just folowing the instructions from documentation
@jgoetz give some more details on errors you get to try to help
I can't figure out how to register new user with social account, followed the documentation and i have a page in existing user profile (that is registered with email) where a social network can be linked, and after that user is able to connect with that social network and it works fine. But how to let user to register with a social network?
John Goetz
I was able to get the Usuario module working under the Basic Template. I found the instructions omitted a couple of configuration settings which would have vexed an inexperienced Yii2 programmer (like myself). I'll post my instructions for others to use and verify.
John Goetz
I wrote these instructions for my setup: Macintosh running MAMP Pro and PHPStorm, with Composer installed globally. YMMV.
I will post my complete config files after this. Do the following steps in order (suggested by the instructions from 2amigos here and augmented by my experience) to create a directory named basic_yii2 in your chosen location.

Install the Basic Template using Composer from the command line and Install the yii2-usuario module:
prompt/> cd PhpstormProjects/wwwrootYii2Portals/ [<-- change to your location]
prompt/> composer create-project --prefer-dist yiisoft/yii2-app-basic basic_yii2
prompt/> cd basic_yii2
prompt/> composer require 2amigos/yii2-usuario:~1.0

Create a database. The basic app default configuration uses the database name yii2basic, but you can change it in the db.php file if you wish.
Create a database user (or use an existing user) then grant all permissions for that user on the database you just created.
I used PHPMyAdmin to create the database and user, but you can use whatever tool you wish.

Modify the file basic_yii2/config/db.php:
Change the database name to whatever you chose above
Change the username to the user you just granted permissions
Change the password to whatever the user above requires

Modify the file basic_yii2/config/console.php (see my follow-on post for my complete console.php file):
Add the modules→user→class declaration
Add the authManager setting to the components section
Change the components→user→identityClass to Da\User\Model\User
Add the components→user→class declaration

Modify the file basic_yii2/config/web.php (see my follow-on post for my complete web.php file):
Add the modules→user→class declaration
Add the authManager setting to the components section
Change the components→user→identityClass to Da\User\Model\User

DO NOT use the console.php file for web.php... there are a couple of settings that won't work for the web app!

In MAMP create a new host declaration.

Run the Usuario migration to create the User, Profile, Social, and Token tables.
prompt/> php7.3.21 yii migrate --migrationNamespaces=Da\\User\\Migration

Run the RBAC migrations to rule, assignment, item, and itemChild tables.
prompt/> php7.3.21 yii migrate --migrationPath=@yii/rbac/migrations

Create a new migration: nd run it (see below for my example):
prompt/> php7.3.21 yii migrate/create add_admin_user_and_role

Edit the migration file you just created, and add the information to create an administrator role and account (see below for my example migration).
Then run the migration:
prompt/> php7.3.21 yii migrate

Test the admin login. Your portal should be available at the name you gave in step 10(a)i. Go to HTTP://your-portal-name/index.php?r=user/login (this is the standard URL, since PrettyURLs aren't turned on yet).
Important! You will not be able to log in from the regular login page (HTTP://your-portal-name/index.php/site/login), since this uses the original User model.