forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserProvider.php
More file actions
65 lines (59 loc) · 1.92 KB
/
UserProvider.php
File metadata and controls
65 lines (59 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace ProcessMaker\Providers;
use Illuminate\Auth\EloquentUserProvider;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
use ProcessMaker\Model\User;
/**
* Our User Provider which assists in finding users in our database
* @package ProcessMaker\Providers
*/
class UserProvider extends EloquentUserProvider
{
/**
* Create our user provider, with the hashing implementation needed
* @param HasherContract $hasher
*/
public function __construct(HasherContract $hasher)
{
parent::__construct($hasher, User::class);
}
/**
* Retrieve a user by a remember me token, which we currently do not support
* @param mixed $identifier
* @param string $token
* @return UserContract|null
*/
public function retrieveByToken($identifier, $token)
{
// We currently do not support a remember me token
return null;
}
/**
* Update a remember token, which we currently do not support
* @param UserContract $user
* @param string $token
* @return null|void
*/
public function updateRememberToken(UserContract $user, $token)
{
// We currently do not support a remember me token
return null;
}
/**
* Retrieve a user by passed in credentials
* If it's by email address, let's try to first get by email
* @param array $credentials
* @return UserContract|\Illuminate\Database\Eloquent\Model|null|static
*/
public function retrieveByCredentials(array $credentials)
{
if(isset($credentials['email'])) {
return User::where('email', $credentials['email'])->first();
} else if(isset($credentials['username'])) {
return User::where('username', $credentials['username'])->first();
}
// No valid credential to find, let's return nothing
return null;
}
}