Giter VIP home page Giter VIP logo

yii2-user's Introduction

Yii 2 User

Yii 2 User - User authentication module

New version released 01/31/2016

This release contains a few small updates and bug fixes. Most notably, I've changed LoginForm.username to LoginForm.email and added a timezone field to app\models\Profile (thanks mnglkhn)

If there are any issues, let me know and I'll get to it asap.

Demo

Features

  • Quick setup - works out of the box so you can see what it does
  • Easily extendable
  • Registration using email and/or username
  • Login using email and/or username
  • Login/register via email (enter email > get link in inbox > click link to login/register)
  • Email confirmation (+ resend functionality)
  • Social authentication (facebook, twitter, google, linkedin, reddit, vkontakte)
  • Account page
    • Updates email, username, and password
    • Requires current password
  • Profile page
    • Lists custom fields for users, e.g., full_name
  • Password recovery
  • Admin crud via GridView

Installation

  • Install Yii 2 using your preferred method
  • Install package via composer "amnah/yii2-user": "^5.0"
  • Update config file config/web.php and config/db.php
// app/config/web.php
return [
    'components' => [
        // NOTE: in the yii2-advanced-app, the user component should be updated in
        // 'frontend/config/main.php' and/or 'backend/config/main.php' (OR you can add it
        // to 'common/config' if you remove it from frontend/backend)
        'user' => [
            'class' => 'amnah\yii2\user\components\User',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => true,
            'messageConfig' => [
                'from' => ['[email protected]' => 'Admin'], // this is needed for sending emails
                'charset' => 'UTF-8',
            ]
        ],
    ],
    'modules' => [
        'user' => [
            'class' => 'amnah\yii2\user\Module',
            // set custom module properties here ...
        ],
    ],
];
// app/config/db.php
return [
    'class' => 'yii\db\Connection',
    // set up db info
];
  • Run migration file
    • php yii migrate --migrationPath=@vendor/amnah/yii2-user/migrations
  • Go to your application in your browser
    • http://localhost/pathtoapp/web/user
    • note: go to user/login instead of site/login
  • Log in as admin using neo/neo (change it!)
  • Set up module properties as desired
  • Optional - Update the nav links in your main layout app/views/layouts/main.php
// app/views/layouts/main.php
<?php
'items' => [
    ['label' => 'Home', 'url' => ['/site/index']],
    ['label' => 'About', 'url' => ['/site/about']],
    ['label' => 'Contact', 'url' => ['/site/contact']],
    ['label' => 'User', 'url' => ['/user']],
    Yii::$app->user->isGuest ?
        ['label' => 'Login', 'url' => ['/user/login']] : // or ['/user/login-email']
        ['label' => 'Logout (' . Yii::$app->user->displayName . ')',
            'url' => ['/user/logout'],
            'linkOptions' => ['data-method' => 'post']],
],

Development Notes

How do I check user permissions?

This package contains a custom permissions system. Every user has a role, and that role has permissions in the form of database columns. It should follow the format: can_{permission name}.

For example, the role table has a column named can_admin by default. To check if the user can perform admin actions:

if (!Yii::$app->user->can("admin")) {
    throw new HttpException(403, 'You are not allowed to perform this action.');
}
// --- or ----
$user = User::findOne(1);
if ($user->can("admin")) {
    // do something
};

Add more database columns for permissions as needed. If you need something more powerful, look into setting up [RBAC] (https://github.com/yiisoft/yii2/blob/master/docs/guide/security-authorization.md#role-based-access-control-rbac).

Note: If you set up an authManager component for RBAC, then Yii::$app->user->can() will use that instead of this module's custom role table.

How do I add captcha to the forms?

Check out this great 3-step guide by dektrium. (Please note that the scenarios for the validation rules will depend on your project requirements.)

How do I add i18n?

// app/config/web.php
return [
    'components' => [
        'i18n' => [
            'translations' => [
                'user' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@app/messages', // example: @app/messages/fr/user.php
                ]
            ],
        ],
    ],
];

How do I extend this package?

You can extend the classes directly. Depending on which ones you need, set the proper config property:

// app/config/web.php
'components' => [
    'user' => [
        'class' => 'app\components\MyUser',
        'identityClass' => 'app\models\MyUser',
    ],
],
'modules' => [
    'user' => [
        'class' => 'app\modules\MyModule',
        'controllerMap' => [
            'default' => 'app\controllers\MyDefaultController',
        ],
        'modelClasses'  => [
            'User' => 'app\models\MyUser', // note: don't forget component user::identityClass above
            'Profile' => 'app\models\MyProfile',
        ],
        'emailViewPath' => '@app/mail/user', // example: @app/mail/user/confirmEmail.php
    ],
],

For view files, you can use the theme component.

// app/config/web.php
'components' => [
    'view' => [
        'theme' => [
            'pathMap' => [
                '@vendor/amnah/yii2-user/views' => '@app/views/user', // example: @app/views/user/default/login.php
            ],
        ],
    ],
],

I need more control. Can I just extend the whole thing?

You can always fork the package and modify it as needed.

Or, if you want, you can integrate the package directly into your app by copying the files. This would make it more difficult to get updates, but it also guarantees that your app won't break after running composer update.

To do so, you can use the helper command CopyController.

  • Add the module to your config/console.php to gain access to the command (Note: this is CONSOLE config)
// app/config/console.php
'modules' => [
    'user' => [
        'class' => 'amnah\yii2\user\Module',
    ],
],
  • Use the php yii user/copy command. For a basic app, you can call the default command without any options
php yii user/copy --from=@vendor/amnah/yii2-user --to=@app/modules/user --namespace=app\\modules\\user
  • Update config to point to your new package
// app/config/web.php + app/config/console.php
'modules' => [
    'user' => [
        'class' => 'app\modules\user\Module',
    ],
],

Alternatively, you can do this manually. Just copy/paste the files wherever you'd like and change the namespaces in the files. Replace amnah\yii2\user with app\modules\user.

Todo

yii2-user's People

Contributors

amnah avatar aneesv avatar gugoan avatar ilyar avatar imtiazmahbub avatar jilizart avatar katenkka avatar lan143 avatar maimake avatar michael-schaefer-eu avatar nrob81 avatar onmotion avatar patroklo avatar sharapeco avatar sheershoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-user's Issues

Facebook Auth

Hi, can you help me with the Facebook authentication? I have set it up it like you say on the notes, only using Google and Facebook, Google one is working fine, but the Facebook one isn't. When I try to auth with the widget i get this:

Exception – yii\base\Exception
Request failed with code: 400, message: {"error":{"message":"Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request","type":"OAuthException","code":100}}

My Facebook App setting are set up correctly (I think) and still I can't do it.

The configuration for the "extensions" component must contain a "class" element.

I am attempting to install this extension and the "Invalid Configuration – yii\base\InvalidConfigException" error keeps getting thrown. my config/web.php is

   <?php

    $params = require(__DIR__ . '/params.php');
   // $config =[
   return [
   'id' => 'basic',
   'basePath' => dirname(__DIR__),
   'bootstrap' => ['log'],
   'components' => [
   'urlManager' => [
      // 'showScriptName' => false,
      // 'enablePrettyUrl' => true
              ],    
    'request' => [
        // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
        'cookieValidationKey' => '',
    ],
    'cache' => [
        'class' => 'yii\caching\FileCache',
    ],

     'vendorPath' => dirname(dirname(DIR)) . '/vendor',
    'extensions' => require(DIR . '/../../vendor/yiisoft/extensions.php'),
    'components' => [
    'cache' => [
    'class' => 'yii\caching\FileCache',
    ],
    'user'=>[
    'class' => 'amnah\yii2\user\components\User',
    ]
    ],
    'modules' => [
    'user' => [
    'class' => 'amnah\yii2\user\Module',
    // set custom module properties here ...
    ],
       ],
         'errorHandler' => [
           'errorAction' => 'site/error',
        ],
        'mailer' => [
          'class' => 'yii\swiftmailer\Mailer',
          // 'useFileTransport' => true,
           // 'messageConfig' => [
           // 'from' => ['[email protected]' => 'Admin'], // this is needed for sending emails
           'charset' => 'UTF-8',
           'useFileTransport' => true,
       ],

       'log' => [
           'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php'),
       ],
   'params' => $params,
   ];



   if (YII_ENV_DEV) {
      // configuration adjustments for 'dev' environment
     $config['bootstrap'][] = 'debug';
     $config['modules']['debug'] = 'yii\debug\Module';

     $config['bootstrap'][] = 'gii';
     $config['modules']['gii'] = 'yii\gii\Module';
 }

return $config;

Any help would be greatly appreciated!

Cookie Validation Key must be Secret

Hello, I made a fresh installation of Yii2 and your module, I already add to my head section on main layout the <?= Html::csrfMetaTags() ?> and throws and exception of yii\web\Request::cookieValidationKey must be configured with a secret key. on the line of csrfMetaTags().

What seems to be the problem? Please Help

profile and account error

When I try to enter on profile or account page it gives the following errors:

Profile:
Getting unknown property: common\models\User::profile
$profile = Yii::$app->user->identity->profile;
controllers/DefaultController.php
Account:
Getting unknown property: common\models\User::currentPassword

Am I missing something?

User::findIdentityByAccessToken() error

Declaration of amnah\yii2\user\models\User::findIdentityByAccessToken() must be compatible with yii\web\IdentityInterface::findIdentityByAccessToken($token, $type = NULL)

With Advanced Application Template, this error happens when I try to login.

Send confirmation Email Error

I Use SwiftMailter to send emails via gmail host, And I got an error when resend confirmation email :
"Cannot send message without a sender address"

Hope to add "setFrom"

return $mailer->compose('confirmEmail', compact("subject", "user", "profile", "userkey"))
            ->setTo($email)
            ->setFrom([Yii::$app->params['adminEmail'] => Yii::$app->params['company']])
            ->setSubject($subject)
            ->send();
```php

migrations

when i run the migrations i get:

Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [2002] No such file or directory'

in /Applications/MAMP/htdocs/yiitest/basic/vendor/yiisoft/yii2/db/Connection.php:534

Translation

Hey!

Is it planned the plugin to translate into other languages​​? I can offer for German, when the preparations are made.

Confirmation email rerouting to localhost and not domain

For some reason eveytime I click the confirmation link email, I get an invalid key exception! any ideas?

no UI errors, but I guess for some reason it is not matching the database key.

Thanks again! great extension by the way!!!!

advanced template yii2

Hi,
I've installed yii2 and I'm trying to customize the standard advanced app template. (https://github.com/yiisoft/yii2-app-advanced)
My project root is /var/www/html/advanced
I've Apache2, PHP Version 5.5.9-1 on ubuntu4.5
I've correctly
-Install Yii 2
-Install package via composer "amnah/yii2-user": "dev-master" which is in /www/html/advanced/vendor
-I've tried to modify 'frontend/config/main.php' and 'backend/config/main.php and below there is my first question
-I've run migration and all goes right; I've test the connection (via a testdb.php file) and I'm able to retrieve data (ID:1 username:neoemail: [email protected])
-I Go to http://localhost/advanced/web/user or http://127.0.0.1/advanced/web/user, and the message is:
Not Found The requested URL /advanced/web/user was not found on this server. Apache/2.4.7 (Ubuntu) Server at 127.0.0.1 Port 80

First issue on point 3 of installation guide:
all path in the guide is amnah\yii2\user (eg.'class' => 'amnah\yii2\user\components\User',) but
in amnah folder user.php is in /amnah/yii2-user/components so yii2-user and no yii2\user
Is correct to modify this path according to the right path?
My final path is so for
'class' => 'amnah\yii2\user\components\User' is
'class' => 'vendor\amnah\yii2-user\components\User'
is it right?

I've tried both path but I've got the same error.

Is there the path http://localhost/advanced/web/user correct? I've no folder web/user

Any idea?
Thank you for your support.

Add a property to take available register feature

Hey guy, thanks a lot for your module, good job! It's save my time!
However, I would suggest that you develop a property in your module to take available register feature, because sometimes we do not want the users make a signup by themselves.

Installing via composer

Hi! I think that you should define a version in your composer.json for your library or, in your readme, change the code to the code that apperars in your packaglist package: "amnah/yii2-user": "dev-master"

I don't know almost anything about composer, so I'm probably wrong saying this, but I have tried the packaglist code and works just fine, but the readme doesn't at least for me.

Running Migrations Fails...

Tried to install this on Yii2... when running the migration, got the following issue:
user@barium:~/web/bootdroid.com/yii$ php yii migrate --migrationPath=@vendor/amnah/yii2-user/amnah/yii2/user/migrations
Error: The 'db' option must refer to the application component ID of a DB connection.

Class 'yii\helpers\Security' not found

PHP Fatal Error – yii\base\ErrorException
Class 'yii\helpers\Security' not found

the only Security i find is yii\base\Security but if i change path doesn't work. I think i'm missing all the Helpers

create_ip and login_ip

Do I have to configure anything else for create_ip and login_ip functionality? They both don't seem be working.

Proposal for README instructions

At first a large Komliment! Really good job for a beta version!

In the documentation it is stated that you can override the view files. Unfortunately, it is with the 'viewPath' option only possible to overwrite all view files at all.

What do you think of the note in the readme that you should use the yii2 theme function? Thus it is possible to outsource specific individual files.

Documentation: http://www.yiiframework.com/doc-2.0/guide-theming.html
Example (Important is only the area "@app/views/user"):

'view' => [
    'theme' => [
        'pathMap' => [
            '@vendor/amnah/yii2-user/views' => ['@theme/views/user', '@app/views/user'],
            '@app/views' => '@theme/views',
        ],
        'baseUrl' => '@theme',
    ],
],

I will continue with my tests ;)

Greetings from Germany

Profile fails to save

When creating a user through the admin interface, the module saves the User model data but not the Profile model data, even though profile data is being returned by $_POST. When I looked at the AdminController, I noticed that it has the line $user->setScenario("admin");, but in Model.php, no scenarios are included. (Actually, DefaultController references register, account, and reset scenarios, none of which are defined in User.php. I haven't tried the functionality that requires those scenarios yet, but I assume that it would also fail.)

Am I missing something here?

migrations are only for mysql not postgresql

table creation is DB specific.

use this instead

    use yii\db\Schema;
    ....
    $tableOptions = null;
    if ($this->db->driverName === 'mysql') {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
    }

    $this->createTable(UserAuth::tableName(), [
        'id' => Schema::TYPE_PK,
        'user_id' => Schema::TYPE_BIGINT. ' NOT NULL',
        'provider' => Schema::TYPE_STRING. ' NOT NULL',
        'provider_id' => Schema::TYPE_STRING. ' NOT NULL',
        'provider_attributes' => Schema::TYPE_TEXT. ' NOT NULL',
        'create_time' => Schema::TYPE_TIMESTAMP. ' default current_timestamp',
        'updated_at' => Schema::TYPE_TIMESTAMP. ' default current_timestamp'
    ], $tableOptions);

and for init_user

    use yii\db\Schma;
    ....

    // create tables. note the specific order
    $this->createTable(Role::tableName(), [
        "id" => Schema::TYPE_PK,
        "name" => Schema::TYPE_STRING. ' NOT NULL',
        "create_time" => Schema::TYPE_TIMESTAMP. ' default current_timestamp',
        "update_time" => Schema::TYPE_TIMESTAMP. ' default current_timestamp',
        "can_admin" => Schema::TYPE_SMALLINT. ' not null default 0',
    ]);

    $this->createTable(User::tableName(), [
        "id" => Schema::TYPE_PK,
        "role_id" => Schema::TYPE_BIGINT.' NOT NULL',
        "status" => Schema::TYPE_SMALLINT." not null",
        "email" => Schema::TYPE_STRING." null default null",
        "new_email" => Schema::TYPE_STRING." null default null",
        "username" => Schema::TYPE_STRING." null default null",
        "password" => Schema::TYPE_STRING." null default null",
        "auth_key" => Schema::TYPE_STRING." null default null",
        "api_key" => Schema::TYPE_STRING." null default null",
        "login_ip" => Schema::TYPE_STRING." null default null",
        "login_time" => Schema::TYPE_TIMESTAMP. ' null default null',
        "create_ip" => Schema::TYPE_STRING." null default null",
        "create_time" => Schema::TYPE_TIMESTAMP. ' default current_timestamp',
        "update_time" => Schema::TYPE_TIMESTAMP. ' default current_timestamp',
        "ban_time" => Schema::TYPE_TIMESTAMP. ' null default null',
        "ban_reason" => Schema::TYPE_STRING." null default null",
    ]);

    $this->createTable(UserKey::tableName(), [
        "id" => Schema::TYPE_PK,
        "user_id" => Schema::TYPE_BIGINT. " not null",
        "type" => Schema::TYPE_SMALLINT. " not null",
        "key" => Schema::TYPE_STRING. " not null",
        "create_time" => Schema::TYPE_TIMESTAMP. ' default current_timestamp',
        "consume_time" => Schema::TYPE_TIMESTAMP. " default null",
        "expire_time" => Schema::TYPE_TIMESTAMP. " default null",
    ]);

    $this->createTable(Profile::tableName(), [
        "id" => Schema::TYPE_PK,
        "user_id" => Schema::TYPE_BIGINT. " not null",
        "create_time" => Schema::TYPE_TIMESTAMP. ' default current_timestamp',
        "update_time" => Schema::TYPE_TIMESTAMP. ' default current_timestamp',
        "full_name" => Schema::TYPE_STRING. " null default null",
    ]);

Field name 'key' should be avoided as it is a reserved keyword (MySQL)

In table definition:
$this->createTable(UserKey::tableName(), [
"id" => "int unsigned not null auto_increment primary key",
"user_id" => "int unsigned not null",
"type" => "tinyint not null",
----> "key" => "varchar(255) not null",
"create_time" => "timestamp null default null",
"consume_time" => "timestamp null default null",
"expire_time" => "timestamp null default null",
]);

My suggestion would be to change field name to 'keyname'.

Question about profile load: yii2-user and yii2-eauth

I`ve installer yii2-user according to instruction. Working fine: registering, editing and so on.

But I have got an error in "/user/profile" controller.
I`m authorized, and in DefaultController->actionProfile() I use

$user = Yii::$app->user->identity;

but $user->profile is empty, so I have an error in $profile->load( $_POST )

Where to find a bug?

Code:
https://github.com/dekmabot/Yii.mishinoleg.ru/blob/master/yii2-basic/vendor/amnah/yii2-user/amnah/yii2/user/controllers/DefaultController.php#L313

You can test it here: http://yii.mishinoleg.ru/

Cannot delete user because (Integrity constraint violation: 1451) foreign dependency key . table 'user', table 'role'

Integrity constraint violation – yii\db\IntegrityException
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (db1.user_key, CONSTRAINT user_key_user_id FOREIGN KEY (user_id) REFERENCES user (id))
The SQL being executed was: DELETE FROM user WHERE id=4

Error Info: Array
(
[0] => 23000
[1] => 1451
[2] => Cannot delete or update a parent row: a foreign key constraint fails (db1.user_key, CONSTRAINT user_key_user_id FOREIGN KEY (user_id) REFERENCES user (id))
)


Caused by: PDOException
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (db1.user_key, CONSTRAINT user_key_user_id FOREIGN KEY (user_id) REFERENCES user (id))

in /var/www/encounter/vendor/yiisoft/yii2/db/Command.php at line 768

error on installation (migration)

hi, when i run the migrate i have this error:

C:\WebServerLocal\MyApp>php yii migrate --migrationPath=@vendor/amnah/yii2
-user/migrations
Yii Migration Tool (based on Yii v2.0.0-dev)

Creating migration history table "migration"...done.
Total 1 new migration to be applied:
m131114_141544_add_user

Apply the above migration? (yes|no) [no]:yes
*** applying m131114_141544_add_user
> create table role ... done (time: 0.011s)
PHP Compile Error 'yii\base\ErrorException' with message 'Declaration of amnah\y
ii2\user\models\User::findIdentityByAccessToken() must be compatible with yii\we
b\IdentityInterface::findIdentityByAccessToken($token, $type = NULL)'

in C:\WebServerLocal\MyApp\vendor\amnah\yii2-user\models\User.php:38

Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

i am running on Windows7 / php 5.4.33, what can i do?
thank's

EDIT: for now i think to fix it changing User.php on line 223
from: public static function findIdentityByAccessToken($token)
to: public static function findIdentityByAccessToken($token, $type = null)

Slow

after login, website it's slow

JSON API for yii2-user

This extension is great, thanks! I was wondering if it does provide JSON API with functions to login. If not, are you please able to point me in the right direction? Thanks

Rbac support to User model

Hi! I have started learning yii2 a week ago and I saw your auth extension (very interesting, I think that I'll use it as default user management in my little projects while I learn this framework). But I saw that you can't use rbac roles in the user objects, I think that it doesn't have a lot of sense while with the User component you can do that, so I have added into my fork some changes into the can() method to fix that.

Are you interested in sending you a pull request with the changes to add this support to the main branch of the project?

thanks!

Manual activation

Is it possible to manually activate users from the admin CRUD? Similar to sending a mail, but without automation.

add verifyCode

Hope that adding configuration for using verifyCode when doing login

Adding Profile fields

What should be the best to add various profile fields ?
Should I use Gii to update models,crud etc?
Please document this feature.

model->user->id not working

In all my tables I have a user_id column.

And, until version 2.0, I could get user id in my views with this code:
$model->relation->user->id;

But now I get an Exception, Trying to get a property of a non object.

Any way to solve this?

Thanks!

How to use profile table

Hello and thank you for this great extension!

I'm a bit confused on how to use the profile table to have additional custom fields for a user. Currently, I'm just trying to get a user with their profile fields.

Do I need to create my own model class for the profile table? I see that in the sample user created when installing the yii2-user extension, the "full name" is "the one". How would I go about selecting that user so I can display the full name field?

Thanks so much!

sqlite and foreign keys

It seems, as the migrate script is not sqlite3 compatible and its way, dealing with foreign keys.
foreign keys need to be added while creating a table in sqlite - adding afterwards is not supported.
Any way this to be fixed?

Not compatible with IdentityInterface

After installing with Composer, I get this error:

PHP Fatal error: Declaration of amnah\yii2\user\models\User::findIdentityByAccessToken() must be compatible with yii\web\IdentityInterface::findIdentityByAccessToken($token, $type = NULL) in webdir/vendor/amnah/yii2-user/models/User.php on line 38

Installation Issue

I am trying to install this from a freshly created project, but after putting "amnah/yii2-user": "*" in composer.json and running composer update, I am encountering the said error:

The requested package amnah/yii2-user could not be found in any version
may be a typo in the package name.

Am I missing something? Please help. Thanks!

Should social login/register work on localhost?

Sorry if it's a stupid question but off a noob with yii framework and social login.register.

Should it work on local host or does it have to be on a live server to test?

Also the code protected function setInfoFacebook which directory/file should that be put in?

Thanks & Awesome Work 👍

Error When Already registered user login with google plus

There is error when Error When Already registered user (Normal register) tries to login with google+

I found where is error in AuthController.php function attemptLogin line number 137

      // attempt to find user by email
    if (!empty($attributes["email"])) {

        // check if any user has `new_email` set and clear it
        $email = trim($attributes["email"]);
        $this->clearNewEmail($email);

        // find user and create user provider for match
        $user = $user::findOne(["email" => $email]);

In case of google email will be inside an array ($attributes["emails"][0]["value"]) , please fix this

Login validation messages

Hey!

Another suggestion from me. ;)

I dont´t like separate error messages for the user name / email and password. So it is easyer to hack the login.

Something like the following would suffice for both fields:
Username or password is incorrect

Security by obscurity

Forbidden (#403)

when i try acces to /user/admin i get this error, what happend?

Installation Problems

Im trying to install yii2-user on my Yii2 basic Project but when i try to use Composer the error is:

[InvalidArgumentException]
There are no commands defined in the "amnah/yii2-user" namespace.

Or when I try to downlad the zip file and extrac into vendor folder the error is:

Class amnah\yii2\user\components\User does not exist

Maybe im doing the wrong steps but I followed the guides.

The last error is on Yii Migrate command:

*** applying m140524_153638_init_user
Exception 'PDOException' with message 'SQLSTATE[42000]: [Microsoft][SQL Server N
ative Client 11.0][SQL Server]A transaction that was started in a MARS batch is
still active at the end of the batch. The transaction is rolled back.'

in C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\db\mssql\PDO.php:36

Stack trace:
#0 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\db\mssql\PDO.php(36): PDO->exec('BEGIN TRANSACTI...')
#1 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\db\Transaction.php(119): yii\db\mssql\PDO->beginTransaction()
#2 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\db\Connection.php(639): yii\db\Transaction->begin(NULL)
#3 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\db\Migration.php(76): yii\db\Connection->beginTransaction()
#4 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(488): yii\db\Migration->up()
#5 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(126): yii\console\controllers\BaseMigrateController->migrateUp('m140524_153638_...')
#6 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#7 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
#8 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\base\Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#9 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\console\Controller.php(91): yii\base\Controller->runAction('', Array)
#10 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\base\Module.php(455): yii\console\Controller->runAction('', Array)
#11 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\console\Application.php(161): yii\base\Module->runAction('migrate', Array)
#12 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\console\Application.php(137): yii\console\Application->runAction('migrate', Array)
#13 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\vendor\yiisoft\yii2\base\Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#14 C:\Users\omaarbte\Documents\My Web Sites\Yii2B\yii(23): yii\base\Application->run()
#15 {main}

[bug] Admin user could delte own account...

... and other admin accounts.

I just noticed, that a user with admin rights could delete itself.

Maybe you should also consider two additional things:

  • Definition of usernames, which can not be deleted (['neo', 'default', 'admin ', ...])
    OR
  • An admin may generally not be deleted by another admin (I would prefer!)

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.