Git Product home page Git Product logo

yii2-user's People

Contributors

amilkov avatar nkostadinov avatar traykovn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-user's Issues

The token table has no PK defined

The token table has no id filed, so the primary key has to be defined in the model nkostadinov\user\models\Token overriding the primaryKey() method.

Database Exception – yii\db\Exception

nkostadinov\user\models\Token does not have a primary key. You should either define a primary key for the corresponding table or override the primaryKey() method.
1. in ...\vendor\yiisoft\yii2\db\BaseActiveRecord.php at line 1001
2. in ...\vendor\yiisoft\yii2\db\ActiveRecord.php at line 589 – yii\db\BaseActiveRecord::getOldPrimaryKey(true)
3. in ...\vendor\yiisoft\yii2\db\ActiveRecord.php at line 558 – yii\db\ActiveRecord::deleteInternal()
4. in ...\vendor\nkostadinov\yii2-user\models\User.php at line 205 – yii\db\ActiveRecord::delete()
5. in ...\vendor\nkostadinov\yii2-user\controllers\RegistrationController.php at line 39 – nkostadinov\user\models\User::confirm(nkostadinov\user\models\Token)
6. nkostadinov\user\controllers\RegistrationController::actionConfirm('...')
7. in ...\vendor\yiisoft\yii2\base\InlineAction.php at line 53 – call_user_func_array([nkostadinov\user\controllers\RegistrationController, 'actionConfirm'], ['...'])
8. in ...\vendor\yiisoft\yii2\base\Controller.php at line 157 – yii\base\InlineAction::runWithParams(['code' => '...'])
9. in ...\vendor\yiisoft\yii2\base\Module.php at line 445 – yii\base\Controller::runAction('confirm', ['code' => '...'])
10. in ...\vendor\yiisoft\yii2\web\Application.php at line 84 – yii\base\Module::runAction('user/registration/confirm/', ['code' => '...'])
11. in ...\vendor\yiisoft\yii2\base\Application.php at line 389 – yii\web\Application::handleRequest(yii\web\Request)
12. in ...\web\index.php at line 12 – yii\base\Application::run()

Username

Can we add username to the rules for the User model when safeAttributes is in play, otherwise the username is not modifiable.
As well, simply from the point of someone learning.

Why
if (($model = Yii::$app->user->listUsers()->andWhere(['id' => $id])->one()) !== null) { return $model;

instead of
if(($model = Yii::$app->user->identity->findIdentity($id))) { return $model;

Thanks for all the great work guys

Custom RegisterForm

What is the recommended approach to implement custom registration form and view?
For example if we need some additional attributes, say DOB or country of birth.

userId is not attribute of the yii\authclient\clients\Facebook

Unknown Property – yii\base\UnknownPropertyException

Getting unknown property: yii\authclient\clients\Facebook::userId
1. in .../vendor/yiisoft/yii2/base/Component.php at line 143
2. in .../vendor/nkostadinov/yii2-user/controllers/SecurityController.php at line 119 – yii\base\Component::__get('userId')
3. nkostadinov\user\controllers\SecurityController::successCallback(yii\authclient\clients\Facebook)
4. in .../vendor/yiisoft/yii2-authclient/AuthAction.php at line 212 – call_user_func([nkostadinov\user\controllers\SecurityController, 'successCallback'], yii\authclient\clients\Facebook)
5. in .../vendor/yiisoft/yii2-authclient/AuthAction.php at line 361 – yii\authclient\AuthAction::authSuccess(yii\authclient\clients\Facebook)
6. in .../vendor/yiisoft/yii2-authclient/AuthAction.php at line 193 – yii\authclient\AuthAction::authOAuth2(yii\authclient\clients\Facebook)
7. in .../vendor/yiisoft/yii2-authclient/AuthAction.php at line 177 – yii\authclient\AuthAction::auth(yii\authclient\clients\Facebook)
8. yii\authclient\AuthAction::run()
9. in .../vendor/yiisoft/yii2/base/Action.php at line 92 – call_user_func_array([yii\authclient\AuthAction, 'run'], [])
10. in .../vendor/yiisoft/yii2/base/Controller.php at line 154 – yii\base\Action::runWithParams(['authclient' => 'facebook', 'code' => 'AQAompZtzhly58-d_hDrhgS0g3hrshOE...'])
11. in .../vendor/yiisoft/yii2/base/Module.php at line 454 – yii\base\Controller::runAction('auth', ['authclient' => 'facebook', 'code' => 'AQAompZtzhly58-d_hDrhgS0g3hrshOE...'])
12. in .../vendor/yiisoft/yii2/web/Application.php at line 84 – yii\base\Module::runAction('user/security/auth', ['authclient' => 'facebook', 'code' => 'AQAompZtzhly58-d_hDrhgS0g3hrshOE...'])
13. in .../vendor/yiisoft/yii2/base/Application.php at line 375 – yii\web\Application::handleRequest(yii\web\Request)
14. in .../web/index.php at line 12 – yii\base\Application::run()

token.expires_on field is null on Signup

Integrity constraint violation – yii\db\IntegrityException

SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "expires_on" violates not-null constraint
The SQL being executed was: INSERT INTO "token" ("type", "user_id", "created_at", "code") VALUES (0, 10, 1460025601, '_Bb_31JFpDcj0BIX_4PvvAHyW-7BLpQT')

in ...\vendor\yiisoft\yii2\db\Command.php at line 809
1. in ...\vendor\yiisoft\yii2\db\Schema.php at line 601
2. in ...\vendor\yiisoft\yii2\db\Command.php at line 824 – yii\db\Schema::convertException(PDOException, 'INSERT INTO "token" ("type", "us...')
3. in ...\vendor\yiisoft\yii2\db\Command.php at line 369 – yii\db\Command::queryInternal('fetch', null)
4. in ...\vendor\yiisoft\yii2\db\pgsql\Schema.php at line 453 – yii\db\Command::queryOne()
5. in ...\vendor\yiisoft\yii2\db\ActiveRecord.php at line 444 – yii\db\pgsql\Schema::insert('token', ['type' => 0, 'user_id' => 10, 'created_at' => 1460025601, 'code' => '_Bb_31JFpDcj0BIX_4PvvAHyW-7BLpQT'])
6. in ...\vendor\yiisoft\yii2\db\ActiveRecord.php at line 415 – yii\db\ActiveRecord::insertInternal(null)
7. in ...\vendor\yiisoft\yii2\db\BaseActiveRecord.php at line 575 – yii\db\ActiveRecord::insert(false, null)
8. in ...\vendor\yiisoft\yii2\db\BaseActiveRecord.php at line 1396 – yii\db\BaseActiveRecord::save(false)
9. in ...\vendor\yiisoft\yii2\db\BaseActiveRecord.php at line 1185 – yii\db\BaseActiveRecord::bindModels(['user_id' => 'id'], nkostadinov\user\models\Token, nkostadinov\user\models\User)
10. in ...\vendor\nkostadinov\yii2-user\components\User.php at line 128 – yii\db\BaseActiveRecord::link('user', nkostadinov\user\models\User)
11. in ...\vendor\nkostadinov\yii2-user\models\forms\SignupForm.php at line 79 – nkostadinov\user\components\User::register(nkostadinov\user\models\User)
12. in ...\vendor\nkostadinov\yii2-user\controllers\RegistrationController.php at line 62 – nkostadinov\user\models\forms\SignupForm::signup()
13. nkostadinov\user\controllers\RegistrationController::actionSignup()
14. in ...\vendor\yiisoft\yii2\base\InlineAction.php at line 53 – call_user_func_array([nkostadinov\user\controllers\RegistrationController, 'actionSignup'], [])
15. in ...\vendor\yiisoft\yii2\base\Controller.php at line 157 – yii\base\InlineAction::runWithParams([])
16. in ...\vendor\yiisoft\yii2\base\Module.php at line 445 – yii\base\Controller::runAction('signup', [])
17. in ...\vendor\yiisoft\yii2\web\Application.php at line 84 – yii\base\Module::runAction('user/registration/signup', [])
18. in ...\vendor\yiisoft\yii2\base\Application.php at line 389 – yii\web\Application::handleRequest(yii\web\Request)
19. in ...\web\index.php at line 12 – yii\base\Application::run()

Attributes that should be empty on NULL

I guess the validators for the attributes that are declared in the schema as NOT NULL, but are unset in some of the use cases has to be changed with rules that looks like
[ 'password_hash', 'default', 'setOnEmpty' => true, 'value' => '' ]

Alternatively the tables DDLs can be altered to accept NULL values

For the moment what I am getting is:

Integrity constraint violation – yii\db\IntegrityException

SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "password_hash" violates not-null constraint
The SQL being executed was: INSERT INTO "user" ("email", "name", "auth_key", "register_ip", "created_at", "updated_at") VALUES ('[email protected]', 'Extremе Arenа', '...', '127.0.0.1', 1460099795, 1460099795) RETURNING "id"

in ...\vendor\yiisoft\yii2\db\Command.php at line 809
1. in ...\vendor\yiisoft\yii2\db\Schema.php at line 601
2. in ...\vendor\yiisoft\yii2\db\Command.php at line 824 – yii\db\Schema::convertException(PDOException, 'INSERT INTO "user" ("email", "na...')
3. in ...\vendor\yiisoft\yii2\db\Command.php at line 369 – yii\db\Command::queryInternal('fetch', null)
4. in ...\vendor\yiisoft\yii2\db\pgsql\Schema.php at line 453 – yii\db\Command::queryOne()
5. in ...\vendor\yiisoft\yii2\db\ActiveRecord.php at line 444 – yii\db\pgsql\Schema::insert('{{%user}}', ['email' => '[email protected]', 'name' => 'Extremе Arenа', 'auth_key' => '...', 'register_ip' => '127.0.0.1', ...])
6. in ...\vendor\yiisoft\yii2\db\ActiveRecord.php at line 415 – yii\db\ActiveRecord::insertInternal(null)
7. in ...\vendor\yiisoft\yii2\db\BaseActiveRecord.php at line 575 – yii\db\ActiveRecord::insert(false, null)
8. in ...\vendor\nkostadinov\yii2-user\components\User.php at line 210 – yii\db\BaseActiveRecord::save(false)
9. in ...\vendor\nkostadinov\yii2-user\components\User.php at line 172 – nkostadinov\user\components\User::createUserByOAuthIfNotExists(nkostadinov\user\accounts\FacebookAccount, nkostadinov\user\models\UserAccount, '[email protected]')
10. in ...\vendor\nkostadinov\yii2-user\controllers\SecurityController.php at line 121 – nkostadinov\user\components\User::oAuthAuthentication(nkostadinov\user\accounts\FacebookAccount)
11. nkostadinov\user\controllers\SecurityController::successCallback(nkostadinov\user\accounts\FacebookAccount)
12. in ...\vendor\yiisoft\yii2-authclient\AuthAction.php at line 212 – call_user_func([nkostadinov\user\controllers\SecurityController, 'successCallback'], nkostadinov\user\accounts\FacebookAccount)
13. in ...\vendor\yiisoft\yii2-authclient\AuthAction.php at line 361 – yii\authclient\AuthAction::authSuccess(nkostadinov\user\accounts\FacebookAccount)
14. in ...\vendor\yiisoft\yii2-authclient\AuthAction.php at line 193 – yii\authclient\AuthAction::authOAuth2(nkostadinov\user\accounts\FacebookAccount)
15. in ...\vendor\yiisoft\yii2-authclient\AuthAction.php at line 177 – yii\authclient\AuthAction::auth(nkostadinov\user\accounts\FacebookAccount)
16. yii\authclient\AuthAction::run()
17. in ...\vendor\yiisoft\yii2\base\Action.php at line 90 – call_user_func_array([yii\authclient\AuthAction, 'run'], [])
18. in ...\vendor\yiisoft\yii2\base\Controller.php at line 157 – yii\base\Action::runWithParams(['authclient' => 'facebook', 'code' => '......'])
19. in ...\vendor\yiisoft\yii2\base\Module.php at line 445 – yii\base\Controller::runAction('auth', ['authclient' => 'facebook', 'code' => '......'])
20. in ...\vendor\yiisoft\yii2\web\Application.php at line 84 – yii\base\Module::runAction('user/security/auth', ['authclient' => 'facebook', 'code' => '......'])
21. in ...\vendor\yiisoft\yii2\base\Application.php at line 389 – yii\web\Application::handleRequest(yii\web\Request)
22. in ...\web\index.php at line 12 – yii\base\Application::run()

generateAuthKey method is never used

The method generateAuthKey of the User class is never used in the registration process or anywhere in the code.
As a result the auth_key field of the user table is null, but it is defined as NOT NULL

ERROR:  null value in column "auth_key" violates not-null constraint

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.