Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
pasquale
@paskuale75
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
@jgoetz
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?
pasquale
@paskuale75
if you don't find alternatives I'm finally using this https://github.com/sjaakp/yii2-pluto
John Goetz
@jgoetz
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
@EndErr
@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
@jgoetz
Success!
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
@jgoetz
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.

My example console.php file:<?php

$params = require DIR . '/params.php';
$db = require DIR . '/db.php';

$config = [
'id' => 'basic-console',
'basePath' => dirname(DIR),
'bootstrap' => ['log'],
'controllerNamespace' => 'app\commands',
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
'@tests' => '@app/tests',
'@Da' => '@vendor/2amigos/yii2-usuario/src'
],
'modules' => [
'user' => [
'class' => Da\User\Module::class,
],
],
'components' => [
'authManager' => [
'class' => 'Da\User\Component\AuthDbManagerComponent',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'Da\User\Model\User',
'class' => 'Da\User\Model\User',
'enableAutoLogin' => true,
],
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
],
'params' => $params,
/
'controllerMap' => [
'fixture' => [ // Fixture generation command line.
'class' => 'yii\faker\FixtureController',
],
],
/
];

if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}

return $config;

pasquale
@paskuale75
@jgoetz thanks, then it works ? I'll try it right awayI'll try it right away
John Goetz
@jgoetz
I apologize for the formatting of the config files!

My complete web.php configuration file:
<?php

$params = require DIR . '/params.php';
$db = require DIR . '/db.php';

$config = [
'id' => 'basic',
'basePath' => dirname(DIR),
'bootstrap' => ['log'],
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
'@Da' => '@vendor/2amigos/yii2-usuario/src'
],
'modules' => [
'user' => [
'class' => Da\User\Module::class,
],
],
'components' => [
'authManager' => [
//'class' => 'yii\rbac\DbManager', // original setting
'class' => 'Da\User\Component\AuthDbManagerComponent',
],
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'M6Pdf__ZcD6xzjNa_nlUagM4rNZwhrSi',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'Da\User\Model\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
],
],
'params' => $params,
];

if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];

$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
    'class' => 'yii\gii\Module',
    // uncomment the following to add your IP if you are not connecting from localhost.
    //'allowedIPs' => ['127.0.0.1', '::1'],
];

}

return $config;

pasquale
@paskuale75
@jgoetz Don't worry, you gave me good news, that the project is still alive, I thought otherwise, okay
John Goetz
@jgoetz

My "administrator migration" file:
<?php

use yii\db\Migration;

/**

  • Class m201202_021321_add_admin_user_and_role
    /
    class m201202_021321_add_admin_user_and_role extends Migration
    {
    /*

    • {@inheritdoc}
      */
      public function safeUp()
      {
      $auth = Yii::$app->authManager;

      // create a role named "administrator"
      $administratorRole = $auth->createRole('administrator');
      $administratorRole->description = 'Administrator';
      $auth->add($administratorRole);

      // create permission for certain tasks
      $permission = $auth->createPermission('user-management');
      $permission->description = 'User Management';
      $auth->add($permission);

      // let administrators do user management
      $auth->addChild($administratorRole, $auth->getPermission('user-management'));

      // create user "admin" with password "verysecret"
      $user = new \Da\User\Model\User([

       'scenario' => 'create',
       'email' => "email@example.com",
       'username' => "admin",
       'password' => "verysecret"  // >6 characters!

      ]);
      $user->confirmed_at = time();
      $user->save();

      // assign role to our admin-user
      $auth->assign($administratorRole, $user->id);
      }

      /**

    • {@inheritdoc}
      */
      public function safeDown()
      {
      $auth = Yii::$app->authManager;

      // delete permission
      $auth->remove($auth->getPermission('user-management'));

      // delete admin-user and administrator role
      $administratorRole = $auth->getRole("administrator");
      $user = \Da\User\Model\User::findOne(['name'=>"admin"]);
      $auth->revoke($administratorRole, $user->id);
      $user->delete();
      $auth->remove($administratorRole);
      }

      /*
      // Use up()/down() to run migration code without a transaction.
      public function up()
      {

      }

      public function down()
      {
      echo "m201202_021321_add_admin_user_and_role cannot be reverted.\n";

      return false;
      }
      */
      }

Anyone attempting this should be able to copy and paste my file content into their Basic Template files. I wasn't able to get the tabs/spacing set up to look pretty here.
Negruzzi Cristian
@EndErr
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?
pasquale
@paskuale75
let's start well ... I installed everything as soon as I try to generate the first user admin (with migration) here is the first exception !! Trying to get property 'enableGdprCompliance' of non-object (/var/www/html/yii2-basic/vendor/2amigos/yii2-usuario/src/User/Model/User.php:167)
pasquale
@paskuale75
[SOLVED] I had to declare the user module in the config/console.php file since it is the migration of a command rightly...
John Goetz
@jgoetz
Yes! You found the fix! Nicely done, sir.
pasquale
@paskuale75
a question: if to extend I create my own module, and start extending models and controllers, should I also specify the path for the views? Or does it render from the extended controller then from its view without the need to specify a pathMap in the 'view' component? tnx
pasquale
@paskuale75
[auto-reply] it seems that it is necessary to specify the pathMap in component 'view'
pasquale
@paskuale75
@EndErr are you talking about the ConnectWidget? Can I ask you in what context do you use it? In login or registration? by default I find it in the login but I think it makes sense in the registration rather. And then I don't know why it opens a popup with the login view inside ...
Negruzzi Cristian
@EndErr
@paskuale75 i foundit in login but not in registration
pasquale
@paskuale75
@EndErr thank you so much, I'm reading here to understand how to exploit the ConnectWidget widget at least with facebook...does anyone have more detailed sources?
pasquale
@paskuale75
Hi all, I just discovered the reason why it did not redirect to the social url for the oAuth2, it is the rules of the urlManager component, any advice on how to make the Usuario url coexist? tnx
pasquale
@paskuale75
[SOLVED] I added this rule: 'user/<action:(auth)>' => '/user/security/<action>'
Claudio Alberti
@cloudeeo
Hello, thank you for the great extension! I was able to install and run it in the Basic Template, I run the migration to create the admin user and I can login, but when trying to access user/admin i get a 403 error... Any idea? Thank you!
pasquale
@paskuale75
@cloudeeo the admin user create it with the migration?
andrewbilham
@andrewbilham
Afternoon All, Has anyone done any work on moving this to bootstrap 4
kiatsing96
@kiatsing96
@cloudeeo i have the same problem, did you find any solution?
pasquale
@paskuale75
Can be solution add admin name in user module settings ?
TylerByte
@TylerByte666

Hey guys!

Having an issue implementing the recaptcha on the Login side of things. Has anyone got this working yet? I just get the error: verification code is incorrect.

2amigos/yii2-usuario#409

pasquale
@paskuale75
is it compatible with bootstrap 4.x ?
Bill
@OceanWind
I'm having a mysterious issue where I am getting logged out within seconds of logging in. I'm using the recommended Usario configuration. Any suggestions where I should look to solve this?
1 reply
pasquale
@paskuale75
@OceanWind it would appear to be a session problem. Try looking between settings such as session life time...
Anastasia
@kovaleva_a_m_twitter

Hello!
I'm having trouble with propper install of yii2-usuario.
It seems like i did all all 3 steps in Getting Started instruction (composer require, migrations and config of user module).
But now my index page gives errow: Getting unknown property: Da\User\Module::isGuest

I also tryed to create the first Administrator during a migration (as on https://yii2-usuario.readthedocs.io/en/latest/helpful-guides/first-steps/)
This was giving error: Exception: Trying to get property 'enableGdprCompliance' of non-object (/home/akovaleva/Projects/my_portret/vendor/2amigos/yii2-usuario/src/User/Model/User.php:167)

Unfortunatly I don't undestend where things went wrong...

config: console.php and web.php
    'authManager'  => [
        'class'        => 'yii\rbac\DbManager',
        //            'defaultRoles' => ['guest'],
    ],

    'user' => [
        'class' => Da\User\Module::class
    ],
pasquale
@paskuale75
There is a way to create the user even if the sending of the email fails ? Maybe the user tries again after sending the confirmation email. Thanks
Negruzzi Cristian
@EndErr
is there a tutorial how to enable social network registration with yii2-usuario?
can't figure out how to implement it, any help will be appreciated
Derek Gifford
@derekisbusy
Hi! I'm trying to get the Userario extension working... I'm receiving this error "Getting unknown property: Da\User\Model\User::isGuest" the isGuest property is not implemented I'm wondering if this is something I need to add. Can't find anything in the docs?
Negruzzi Cristian
@EndErr
You should use: Yii::$app->user->isGuest
Wei-Hwa Huang
@onigame
Hi, does anyone know of a guide to transition from dektrium yii2-user to yii2-usuario ?
Negruzzi Cristian
@EndErr
did anyone manage how to setup social network registration?
i cant figure out how to deal with the popup window on a PC, on mobile it works fine
Miriam Barroso
@miriambarroso
Hi, how to resolve the error: Getting unknown property: Da\User\Module::isGuest? I'm using yii2-usuario, my config/web.php this: <code>'user' => [
'class' => Da\User\Module::class,
'classMap' => [
'User' => app\models\User::class,
],
], </code>
osama.sado
@osama.sado:matrix.org
[m]
Hi, how can I install this extention with bootstrap5?
1 reply
  • yiisoft/yii2-bootstrap[2.0.1, ..., 2.0.8] require bower-asset/bootstrap 3.3. | 3.2. | 3.1.* -> found bower-asset/bootstrap[v3.1.0, ..., v3.3.7] but the package is fixed to v5.1.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.