Zizaco / confide

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

Soft delete in users table fetch wrong user #449

Open sumanta-ghosh opened 10 years ago

sumanta-ghosh commented 10 years ago

In log in attempt time I got this sql Array ( [query] => select * from site_users where site_users.deleted_at is null and email = ? or username = ? [bindings] => Array ( [0] => sumanta3 [1] => sumanta3 )

[time] => 14.53

)

Out put of this query is bellow image. and laravel return first row which marked as deleted and I don't want, I want only 2nd row which is not deleted. confide

Above SQL is wrong , parenthesis is missing there

select * from site_users where site_users.deleted_at is null and (email = ? or username = ?)

It will give the proper result

sumanta-ghosh commented 10 years ago

I modified getUserByIdentity methos in \vendor\zizaco\confide\src\Confide\EloquentRepository.php

public function getUserByIdentity($identity) {
    $user = $this->model();
    $condition = function($query) use ($identity) {
                $firstWhere = true;
                foreach ($identity as $attribute => $value) {
                    if ($firstWhere) {
                        $query->where($attribute, '=', $value);
                    } else {
                        $query->orWhere($attribute, '=', $value);
                    }
                    $firstWhere = false;
                }
            };
    return $user->where($condition)->get()->first();
}

I don't know whether is't right process or wrong but it return me the correct result .

ghost commented 10 years ago

check this pr #421

sumanta-ghosh commented 10 years ago

No that is not my problem. My problem is different. Please check my image which I attache and check my requirement again

ghost commented 10 years ago

yep, I made a commit yesterday in that pr #421 to fix this soft delete problem after reading your issue.

Zizaco commented 9 years ago

@sumanta-ghosh I'm gonna take a look on this and make sure that Confide 4 will work well with Laravel soft deletion.

ghost commented 9 years ago

@Zizaco glad that you're back. I believe this issue is finally resolved and merged in #464