Skip to content

Commit

Permalink
Fix incorrect fetching of user record when no attributes are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Oct 20, 2021
1 parent c917ae6 commit 9d16ef3
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Controllers/CypressController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ public function login(Request $request)
{
$attributes = $request->input('attributes', []);

$user = app($this->userClassName())
->newQuery()
->where($attributes)
->first();

if (!$user) {
$user = $this->factoryBuilder($this->userClassName())->create(
$attributes
);
if (empty($attributes)) {
$user = $this->factoryBuilder($this->userClassName())->create();
} else {
$user = app($this->userClassName())
->newQuery()
->where($attributes)
->first();

if (!$user) {
$user = $this->factoryBuilder($this->userClassName())->create(
$attributes
);
}
}

return tap($user, function ($user) {
Expand Down

0 comments on commit 9d16ef3

Please sign in to comment.