Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 0fa1791

Browse files
committed
2 parents 4579cb5 + 3e067c2 commit 0fa1791

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+237
-238
lines changed

src/AdldapAuthServiceProvider.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
namespace Adldap\Laravel;
44

5-
use RuntimeException;
65
use Adldap\AdldapInterface;
7-
use Adldap\Laravel\Resolvers\UserResolver;
8-
use Adldap\Laravel\Resolvers\ResolverInterface;
9-
use Adldap\Laravel\Commands\Console\Import;
106
use Adldap\Laravel\Auth\DatabaseUserProvider;
7+
use Adldap\Laravel\Commands\Console\Import;
8+
use Adldap\Laravel\Resolvers\ResolverInterface;
9+
use Adldap\Laravel\Resolvers\UserResolver;
10+
use Illuminate\Auth\Events\Authenticated;
11+
use Illuminate\Auth\Events\Login;
12+
use Illuminate\Contracts\Hashing\Hasher;
1113
use Illuminate\Support\Facades\Auth;
12-
use Illuminate\Support\Facades\Event;
1314
use Illuminate\Support\Facades\Config;
15+
use Illuminate\Support\Facades\Event;
1416
use Illuminate\Support\ServiceProvider;
15-
use Illuminate\Contracts\Hashing\Hasher;
16-
use Illuminate\Auth\Events\Login;
17-
use Illuminate\Auth\Events\Authenticated;
17+
use RuntimeException;
1818

1919
class AdldapAuthServiceProvider extends ServiceProvider
2020
{
@@ -31,7 +31,7 @@ public function boot()
3131
});
3232

3333
if ($this->app->runningInConsole()) {
34-
$config = __DIR__ . '/Config/auth.php';
34+
$config = __DIR__.'/Config/auth.php';
3535

3636
$this->publishes([
3737
$config => config_path('ldap_auth.php'),
@@ -78,7 +78,7 @@ public function register()
7878
* @param array $config
7979
*
8080
* @throws RuntimeException
81-
*
81+
*
8282
* @return \Illuminate\Contracts\Auth\UserProvider
8383
*/
8484
protected function makeUserProvider(Hasher $hasher, array $config)
@@ -92,16 +92,16 @@ protected function makeUserProvider(Hasher $hasher, array $config)
9292
// otherwise we will try to use the providers config array.
9393
$model = Config::get('ldap_auth.model') ?? array_get($config, 'model');
9494

95-
if (! $model) {
95+
if (!$model) {
9696
throw new RuntimeException(
9797
"No model is configured. You must configure a model to use with the {$provider}."
9898
);
9999
}
100100

101101
return new $provider($hasher, $model);
102102
}
103-
104-
return new $provider;
103+
104+
return new $provider();
105105
}
106106

107107
/**

src/AdldapServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use Adldap\Adldap;
66
use Adldap\AdldapException;
77
use Adldap\AdldapInterface;
8-
use Adldap\Connections\Provider;
98
use Adldap\Connections\ConnectionInterface;
9+
use Adldap\Connections\Provider;
1010
use Illuminate\Container\Container;
1111
use Illuminate\Support\Facades\Config;
1212
use Illuminate\Support\ServiceProvider;
@@ -38,7 +38,7 @@ public function boot()
3838
}
3939

4040
if ($this->app->runningInConsole()) {
41-
$config = __DIR__ . '/Config/config.php';
41+
$config = __DIR__.'/Config/config.php';
4242

4343
$this->publishes([
4444
$config => config_path('ldap.php'),

src/Auth/DatabaseUserProvider.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
namespace Adldap\Laravel\Auth;
44

5-
use Adldap\Models\User;
6-
use Adldap\Laravel\Facades\Resolver;
75
use Adldap\Laravel\Commands\Import;
86
use Adldap\Laravel\Commands\SyncPassword;
9-
use Adldap\Laravel\Traits\ValidatesUsers;
10-
use Adldap\Laravel\Events\Imported;
7+
use Adldap\Laravel\Events\AuthenticatedWithCredentials;
118
use Adldap\Laravel\Events\AuthenticationRejected;
129
use Adldap\Laravel\Events\AuthenticationSuccessful;
1310
use Adldap\Laravel\Events\DiscoveredWithCredentials;
14-
use Adldap\Laravel\Events\AuthenticatedWithCredentials;
15-
use Illuminate\Support\Facades\Bus;
16-
use Illuminate\Support\Facades\Event;
17-
use Illuminate\Support\Facades\Config;
11+
use Adldap\Laravel\Events\Imported;
12+
use Adldap\Laravel\Facades\Resolver;
13+
use Adldap\Laravel\Traits\ValidatesUsers;
14+
use Adldap\Models\User;
1815
use Illuminate\Auth\EloquentUserProvider;
1916
use Illuminate\Contracts\Auth\Authenticatable;
17+
use Illuminate\Support\Facades\Bus;
18+
use Illuminate\Support\Facades\Config;
19+
use Illuminate\Support\Facades\Event;
2020

2121
class DatabaseUserProvider extends EloquentUserProvider
2222
{

src/Auth/NoDatabaseUserProvider.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Adldap\Laravel\Auth;
44

5-
use Adldap\Laravel\Facades\Resolver;
6-
use Adldap\Laravel\Traits\ValidatesUsers;
5+
use Adldap\Laravel\Events\AuthenticatedWithCredentials;
76
use Adldap\Laravel\Events\AuthenticationRejected;
87
use Adldap\Laravel\Events\AuthenticationSuccessful;
98
use Adldap\Laravel\Events\DiscoveredWithCredentials;
10-
use Adldap\Laravel\Events\AuthenticatedWithCredentials;
11-
use Illuminate\Support\Facades\Event;
12-
use Illuminate\Contracts\Auth\UserProvider;
9+
use Adldap\Laravel\Facades\Resolver;
10+
use Adldap\Laravel\Traits\ValidatesUsers;
1311
use Illuminate\Contracts\Auth\Authenticatable;
12+
use Illuminate\Contracts\Auth\UserProvider;
13+
use Illuminate\Support\Facades\Event;
1414

1515
class NoDatabaseUserProvider implements UserProvider
1616
{
@@ -35,7 +35,6 @@ public function retrieveByToken($identifier, $token)
3535
{
3636
// We can't retrieve LDAP users via remember
3737
// token, as we have nowhere to store them.
38-
return;
3938
}
4039

4140
/**

src/Commands/Console/Import.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
namespace Adldap\Laravel\Commands\Console;
44

5-
use Exception;
6-
use RuntimeException;
7-
use UnexpectedValueException;
8-
use Adldap\Models\User;
5+
use Adldap\Laravel\Commands\Import as ImportUser;
6+
use Adldap\Laravel\Commands\SyncPassword;
97
use Adldap\Laravel\Events\Imported;
108
use Adldap\Laravel\Facades\Resolver;
11-
use Adldap\Laravel\Commands\SyncPassword;
12-
use Adldap\Laravel\Commands\Import as ImportUser;
9+
use Adldap\Models\User;
10+
use Exception;
1311
use Illuminate\Console\Command;
12+
use Illuminate\Database\Eloquent\Model;
1413
use Illuminate\Support\Facades\Bus;
15-
use Illuminate\Support\Facades\Event;
1614
use Illuminate\Support\Facades\Config;
17-
use Illuminate\Database\Eloquent\Model;
15+
use Illuminate\Support\Facades\Event;
16+
use RuntimeException;
17+
use UnexpectedValueException;
1818

1919
class Import extends Command
2020
{
@@ -47,10 +47,10 @@ class Import extends Command
4747
/**
4848
* Execute the console command.
4949
*
50-
* @return void
51-
*
5250
* @throws RuntimeException
5351
* @throws \Adldap\Models\ModelNotFoundException
52+
*
53+
* @return void
5454
*/
5555
public function handle()
5656
{
@@ -59,8 +59,8 @@ public function handle()
5959
$count = count($users);
6060

6161
if ($count === 0) {
62-
throw new RuntimeException("There were no users found to import.");
63-
} else if ($count === 1) {
62+
throw new RuntimeException('There were no users found to import.');
63+
} elseif ($count === 1) {
6464
$this->info("Found user '{$users[0]->getCommonName()}'.");
6565
} else {
6666
$this->info("Found {$count} user(s).");
@@ -74,14 +74,14 @@ public function handle()
7474
}
7575

7676
if (
77-
! $this->input->isInteractive() ||
77+
!$this->input->isInteractive() ||
7878
$this->confirm('Would you like these users to be imported / synchronized?', $default = true)
7979
) {
8080
$imported = $this->import($users);
8181

8282
$this->info("Successfully imported / synchronized {$imported} user(s).");
8383
} else {
84-
$this->info("Okay, no users were imported / synchronized.");
84+
$this->info('Okay, no users were imported / synchronized.');
8585
}
8686
}
8787

@@ -151,9 +151,9 @@ public function display(array $users = [])
151151

152152
array_map(function (User $user) use (&$data) {
153153
$data[] = [
154-
'name' => $user->getCommonName(),
154+
'name' => $user->getCommonName(),
155155
'account_name' => $user->getAccountName(),
156-
'upn' => $user->getUserPrincipalName(),
156+
'upn' => $user->getUserPrincipalName(),
157157
];
158158
}, $users);
159159

@@ -195,9 +195,9 @@ public function isRestoring() : bool
195195
/**
196196
* Retrieves users to be imported.
197197
*
198-
* @return array
199-
*
200198
* @throws \Adldap\Models\ModelNotFoundException
199+
*
200+
* @return array
201201
*/
202202
public function getUsers() : array
203203
{
@@ -285,15 +285,15 @@ protected function restore(User $user, Model $model)
285285
* @param User $user
286286
* @param Model $model
287287
*
288-
* @return void
289-
*
290288
* @throws Exception
289+
*
290+
* @return void
291291
*/
292292
protected function delete(User $user, Model $model)
293293
{
294294
if (
295295
$this->isUsingSoftDeletes($model) &&
296-
! $model->trashed() &&
296+
!$model->trashed() &&
297297
$user->isDisabled()
298298
) {
299299
// If deleting is enabled, the model supports soft deletes, the model
@@ -316,19 +316,19 @@ protected function delete(User $user, Model $model)
316316
*/
317317
protected function model() : Model
318318
{
319-
if (! $this->model) {
319+
if (!$this->model) {
320320
$this->model = $this->option('model') ?? Config::get('ldap_auth.model') ?: $this->determineModel();
321321
}
322322

323-
return new $this->model;
323+
return new $this->model();
324324
}
325325

326326
/**
327327
* Retrieves the model by checking the configured LDAP authentication providers.
328328
*
329-
* @return string
330-
*
331329
* @throws UnexpectedValueException
330+
*
331+
* @return string
332332
*/
333333
protected function determineModel()
334334
{

src/Commands/Import.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Adldap\Laravel\Commands;
44

5-
use UnexpectedValueException;
6-
use Adldap\Models\User;
7-
use Adldap\Laravel\Facades\Resolver;
85
use Adldap\Laravel\Events\Importing;
96
use Adldap\Laravel\Events\Synchronized;
107
use Adldap\Laravel\Events\Synchronizing;
11-
use Illuminate\Support\Facades\Event;
12-
use Illuminate\Support\Facades\Config;
8+
use Adldap\Laravel\Facades\Resolver;
9+
use Adldap\Models\User;
1310
use Illuminate\Database\Eloquent\Model;
11+
use Illuminate\Support\Facades\Config;
12+
use Illuminate\Support\Facades\Event;
13+
use UnexpectedValueException;
1414

1515
class Import
1616
{
@@ -69,7 +69,7 @@ public function handle()
6969
// we'll create a new one for them.
7070
$model = $this->findUser() ?: $this->model->newInstance();
7171

72-
if (! $model->exists) {
72+
if (!$model->exists) {
7373
Event::dispatch(new Importing($this->user, $model));
7474
}
7575

@@ -85,9 +85,9 @@ public function handle()
8585
/**
8686
* Retrieves an eloquent user by their GUID or their username.
8787
*
88-
* @return Model|null
89-
*
9088
* @throws UnexpectedValueException
89+
*
90+
* @return Model|null
9191
*/
9292
protected function findUser()
9393
{
@@ -148,9 +148,9 @@ protected function sync(Model $model)
148148
/**
149149
* Returns the LDAP users configured username.
150150
*
151-
* @return string
152-
*
153151
* @throws UnexpectedValueException
152+
*
153+
* @return string
154154
*/
155155
protected function getUserUsername()
156156
{
@@ -170,9 +170,9 @@ protected function getUserUsername()
170170
/**
171171
* Returns the LDAP users object GUID.
172172
*
173-
* @return string
174-
*
175173
* @throws UnexpectedValueException
174+
*
175+
* @return string
176176
*/
177177
protected function getUserObjectGuid()
178178
{
@@ -210,7 +210,7 @@ protected function getLdapSyncAttributes()
210210
{
211211
return Config::get('ldap_auth.sync_attributes', [
212212
'email' => 'userprincipalname',
213-
'name' => 'cn',
213+
'name' => 'cn',
214214
]);
215215
}
216216
}

src/Commands/SyncPassword.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Adldap\Laravel\Commands;
44

5-
use Illuminate\Support\Str;
6-
use Illuminate\Support\Facades\Hash;
7-
use Illuminate\Support\Facades\Config;
85
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Support\Facades\Config;
7+
use Illuminate\Support\Facades\Hash;
8+
use Illuminate\Support\Str;
99

1010
class SyncPassword
1111
{
@@ -86,7 +86,7 @@ protected function passwordNeedsUpdate($password = null) : bool
8686
$current = $this->currentModelPassword();
8787

8888
if ($current !== null && $this->canSync()) {
89-
return ! Hash::check($password, $current);
89+
return !Hash::check($password, $current);
9090
}
9191

9292
return is_null($current);
@@ -99,7 +99,7 @@ protected function passwordNeedsUpdate($password = null) : bool
9999
*/
100100
protected function hasPasswordColumn() : bool
101101
{
102-
return ! is_null($this->column());
102+
return !is_null($this->column());
103103
}
104104

105105
/**

src/Commands/UserImportScope.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace Adldap\Laravel\Commands;
44

55
use Adldap\Laravel\Facades\Resolver;
6-
use Illuminate\Database\Eloquent\Scope;
7-
use Illuminate\Database\Eloquent\Model;
86
use Illuminate\Database\Eloquent\Builder;
7+
use Illuminate\Database\Eloquent\Model;
8+
use Illuminate\Database\Eloquent\Scope;
99

1010
class UserImportScope implements Scope
1111
{

0 commit comments

Comments
 (0)