Zizaco / confide

Confide is a authentication solution for Laravel 4
1.19k stars 258 forks source link

fix EloquentRepository getUserByIdentity query field when its value is empty #421

Closed ghost closed 10 years ago

ghost commented 10 years ago

@Zizaco this is a pr related to the issue that @Doublemedia mentioned in #402

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' (SQL: select * from users where username = )

I reproduce the problem on a brand-new installation.

In the validateIsUnique, the username field will be set to empty when username is optional.

Then it'll call EloquentRepository->getUserByIdentity, which will generate query something like this.

User::where('username','=','')->get();

And laravel will still look up the field username which doesn't exist so it cause the error.

coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.0%) when pulling 3b397a2cdb2f5f78688cc31e4ca26823948e3a64 on wppd:fix-checking-username-field into 8daf6cc50335daf460b7d84a0b1185000e0ce042 on Zizaco:username-optional.

Swiek commented 10 years ago

This fixed the issue!

ghost commented 10 years ago

I think the best solution is to add a config "optional_username" and check in getUserByIdentity

@Doublemedia spotted another username field not exists issue in getUserByEmailOrUsername

Swiek commented 10 years ago

Do you have any suggestions to solve the issue that it will overwrite the edited files that arent in the package username-optional package, when i will run an composer update.

coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.02%) when pulling b1dc274423f8b9706b62533ca513a6384f65457b on wppd:fix-checking-username-field into 8daf6cc50335daf460b7d84a0b1185000e0ce042 on Zizaco:username-optional.

ghost commented 10 years ago

@Doublemedia

You can follow this https://getcomposer.org/doc/05-repositories.md#vcs to use my fork.

Swiek commented 10 years ago

Interesting. What i don't understand yet is do i update the main composer.js in the root or the vendor composer file.

If it's the project composer file how do i edit it?

{ "repositories": [ { "type": "vcs", "url": "https://github.com/igorw/monolog" } ], "require": { "monolog/monolog": "dev-bugfix" } }

Do i remove the confide require or ..?

ghost commented 10 years ago

change url to https://github.com/wppd/confide

require "zizaco/confide": "dev-fix-checking-username-field"

Swiek commented 10 years ago

Up and running! Thx for the help.

coveralls commented 10 years ago

Coverage Status

Coverage decreased (-2.52%) when pulling c17675a6f239ac70a104c36c97718769baaacee8 on wppd:fix-checking-username-field into 8daf6cc50335daf460b7d84a0b1185000e0ce042 on Zizaco:username-optional.

coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.03%) when pulling 75a0a3e96bb779838a4423eecc8eb673f134abde on wppd:fix-checking-username-field into 8daf6cc50335daf460b7d84a0b1185000e0ce042 on Zizaco:username-optional.

coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.69%) when pulling ef9db2af85a81e1ef09bb96974e2609ade8f541f on wppd:fix-checking-username-field into 8daf6cc50335daf460b7d84a0b1185000e0ce042 on Zizaco:username-optional.

hotmeteor commented 10 years ago

Was this merged in? Why was the branch deleted?