Skip to content

Commit b3f2c7b

Browse files
committed
Add username config to specify column.
Fix #15
1 parent 73ebd6f commit b3f2c7b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

config/config.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,15 @@
3030
| the default location
3131
|
3232
*/
33-
'schema' => null
33+
'schema' => null,
34+
/*
35+
|--------------------------------------------------------------------------
36+
| Username Column
37+
|--------------------------------------------------------------------------
38+
|
39+
| What column should be use for the username in the users table to find
40+
| the user.
41+
|
42+
*/
43+
'username' => 'email'
3444
];

src/GraphQL/Mutations/Login.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public function resolve($rootValue, array $args, GraphQLContext $context = null,
1919
{
2020
$credentials = $this->buildCredentials($args);
2121
$response = $this->makeRequest($credentials);
22-
$user = app(config('auth.providers.users.model'))->where('email', $args['data']['username'])->firstOrFail();
22+
$model = app(config('auth.providers.users.model'));
23+
$user = $model->where(config('lighthouse-graphql-passport.username'), $args['data']['username'])->firstOrFail();
2324
$response['user'] = $user;
2425
return $response;
2526
}

0 commit comments

Comments
 (0)