Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from yajra/oracle-user-provider
[5.3] Implement oracle user provider.
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Yajra\Oci8\Auth; | ||
|
||
use Illuminate\Auth\EloquentUserProvider; | ||
use Illuminate\Support\Str; | ||
|
||
class OracleUserProvider extends EloquentUserProvider | ||
{ | ||
/** | ||
* Retrieve a user by the given credentials. | ||
* | ||
* @param array $credentials | ||
* @return \Illuminate\Contracts\Auth\Authenticatable|null | ||
*/ | ||
public function retrieveByCredentials(array $credentials) | ||
{ | ||
if (empty($credentials)) { | ||
return; | ||
} | ||
|
||
// First we will add each credential element to the query as a where clause. | ||
// Then we can execute the query and, if we found a user, return it in a | ||
// Eloquent User "model" that will be utilized by the Guard instances. | ||
$query = $this->createModel()->newQuery(); | ||
|
||
foreach ($credentials as $key => $value) { | ||
if (! Str::contains($key, 'password')) { | ||
$query->whereRaw("upper({$key}) = upper(?)", [$value]); | ||
} | ||
} | ||
|
||
return $query->first(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters