]> BookStack Code Mirror - bookstack/blob - app/Auth/Access/ExternalBaseUserProvider.php
Fixes padding issues of the sidebar's items
[bookstack] / app / Auth / Access / ExternalBaseUserProvider.php
1 <?php
2
3 namespace BookStack\Auth\Access;
4
5 use Illuminate\Contracts\Auth\Authenticatable;
6 use Illuminate\Contracts\Auth\UserProvider;
7
8 class ExternalBaseUserProvider implements UserProvider
9 {
10     /**
11      * The user model.
12      *
13      * @var string
14      */
15     protected $model;
16
17     /**
18      * LdapUserProvider constructor.
19      *
20      * @param $model
21      */
22     public function __construct(string $model)
23     {
24         $this->model = $model;
25     }
26
27     /**
28      * Create a new instance of the model.
29      *
30      * @return \Illuminate\Database\Eloquent\Model
31      */
32     public function createModel()
33     {
34         $class = '\\' . ltrim($this->model, '\\');
35
36         return new $class();
37     }
38
39     /**
40      * Retrieve a user by their unique identifier.
41      *
42      * @param mixed $identifier
43      *
44      * @return \Illuminate\Contracts\Auth\Authenticatable|null
45      */
46     public function retrieveById($identifier)
47     {
48         return $this->createModel()->newQuery()->find($identifier);
49     }
50
51     /**
52      * Retrieve a user by their unique identifier and "remember me" token.
53      *
54      * @param mixed  $identifier
55      * @param string $token
56      *
57      * @return \Illuminate\Contracts\Auth\Authenticatable|null
58      */
59     public function retrieveByToken($identifier, $token)
60     {
61         return null;
62     }
63
64     /**
65      * Update the "remember me" token for the given user in storage.
66      *
67      * @param \Illuminate\Contracts\Auth\Authenticatable $user
68      * @param string                                     $token
69      *
70      * @return void
71      */
72     public function updateRememberToken(Authenticatable $user, $token)
73     {
74         //
75     }
76
77     /**
78      * Retrieve a user by the given credentials.
79      *
80      * @param array $credentials
81      *
82      * @return \Illuminate\Contracts\Auth\Authenticatable|null
83      */
84     public function retrieveByCredentials(array $credentials)
85     {
86         // Search current user base by looking up a uid
87         $model = $this->createModel();
88
89         return $model->newQuery()
90             ->where('external_auth_id', $credentials['external_auth_id'])
91             ->first();
92     }
93
94     /**
95      * Validate a user against the given credentials.
96      *
97      * @param \Illuminate\Contracts\Auth\Authenticatable $user
98      * @param array                                      $credentials
99      *
100      * @return bool
101      */
102     public function validateCredentials(Authenticatable $user, array $credentials)
103     {
104         // Should be done in the guard.
105         return false;
106     }
107 }