Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/Auth/DatabaseUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Adldap\Laravel\Events\DiscoveredWithCredentials;
use Adldap\Laravel\Events\AuthenticatedWithCredentials;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Config;
use Illuminate\Auth\EloquentUserProvider;
use Illuminate\Contracts\Hashing\Hasher;
Expand Down Expand Up @@ -104,7 +103,7 @@ public function retrieveByCredentials(array $credentials)
// Set the currently authenticating LDAP user.
$this->user = $user;

Event::fire(new DiscoveredWithCredentials($user));
event(new DiscoveredWithCredentials($user));

// Import / locate the local user account.
return Bus::dispatch(
Expand All @@ -126,7 +125,7 @@ public function validateCredentials(Authenticatable $model, array $credentials)
// If an LDAP user was discovered, we can go
// ahead and try to authenticate them.
if (Resolver::authenticate($this->user, $credentials)) {
Event::fire(new AuthenticatedWithCredentials($this->user, $model));
event(new AuthenticatedWithCredentials($this->user, $model));

// Here we will perform authorization on the LDAP user. If all
// validation rules pass, we will allow the authentication
Expand All @@ -142,15 +141,15 @@ public function validateCredentials(Authenticatable $model, array $credentials)
if ($model->wasRecentlyCreated) {
// If the model was recently created, they
// have been imported successfully.
Event::fire(new Imported($this->user, $model));
event(new Imported($this->user, $model));
}

Event::fire(new AuthenticationSuccessful($this->user, $model));
event(new AuthenticationSuccessful($this->user, $model));

return true;
}

Event::fire(new AuthenticationRejected($this->user, $model));
event(new AuthenticationRejected($this->user, $model));
}

// LDAP Authentication failed.
Expand Down
9 changes: 4 additions & 5 deletions src/Auth/NoDatabaseUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Adldap\Laravel\Events\AuthenticationSuccessful;
use Adldap\Laravel\Events\DiscoveredWithCredentials;
use Adldap\Laravel\Events\AuthenticatedWithCredentials;
use Illuminate\Support\Facades\Event;
use Illuminate\Contracts\Auth\Authenticatable;

class NoDatabaseUserProvider extends Provider
Expand Down Expand Up @@ -46,7 +45,7 @@ public function updateRememberToken(Authenticatable $user, $token)
public function retrieveByCredentials(array $credentials)
{
if ($user = Resolver::byCredentials($credentials)) {
Event::fire(new DiscoveredWithCredentials($user));
event(new DiscoveredWithCredentials($user));

return $user;
}
Expand All @@ -58,15 +57,15 @@ public function retrieveByCredentials(array $credentials)
public function validateCredentials(Authenticatable $user, array $credentials)
{
if (Resolver::authenticate($user, $credentials)) {
Event::fire(new AuthenticatedWithCredentials($user));
event(new AuthenticatedWithCredentials($user));

if ($this->passesValidation($user)) {
Event::fire(new AuthenticationSuccessful($user));
event(new AuthenticationSuccessful($user));

return true;
}

Event::fire(new AuthenticationRejected($user));
event(new AuthenticationRejected($user));
}

return false;
Expand Down
3 changes: 1 addition & 2 deletions src/Commands/Console/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Adldap\Laravel\Commands\Import as ImportUser;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Config;
use Illuminate\Database\Eloquent\Model;

Expand Down Expand Up @@ -234,7 +233,7 @@ protected function save(User $user, Model $model) : bool
if ($model->save() && $model->wasRecentlyCreated) {
$imported = true;

Event::fire(new Imported($user, $model));
event(new Imported($user, $model));

// Log the successful import.
if ($this->isLogging()) {
Expand Down
7 changes: 3 additions & 4 deletions src/Commands/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Adldap\Laravel\Events\Importing;
use Adldap\Laravel\Events\Synchronized;
use Adldap\Laravel\Events\Synchronizing;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Config;
use Illuminate\Database\Eloquent\Model;

Expand Down Expand Up @@ -52,14 +51,14 @@ public function handle()
$model = $this->findUser() ?: $this->model->newInstance();

if (! $model->exists) {
Event::fire(new Importing($this->user, $model));
event(new Importing($this->user, $model));
}

Event::fire(new Synchronizing($this->user, $model));
event(new Synchronizing($this->user, $model));

$this->sync($model);

Event::fire(new Synchronized($this->user, $model));
event(new Synchronized($this->user, $model));

return $model;
}
Expand Down
5 changes: 2 additions & 3 deletions src/Middleware/WindowsAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Illuminate\Http\Request;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Config;

class WindowsAuthenticate
Expand Down Expand Up @@ -105,12 +104,12 @@ protected function retrieveAuthenticatedUser($username)
*
* @param User $user
* @param mixed|null $model
*
*
* @return void
*/
protected function fireAuthenticatedEvent(User $user, $model = null)
{
Event::fire(new AuthenticatedWithWindows($user, $model));
event(new AuthenticatedWithWindows($user, $model));
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/Resolvers/UserResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Adldap\Laravel\Events\AuthenticationFailed;
use Adldap\Laravel\Auth\NoDatabaseUserProvider;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Config;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Auth\Authenticatable;
Expand Down Expand Up @@ -113,15 +112,15 @@ public function authenticate(User $user, array $credentials = [])

$password = $this->getPasswordFromCredentials($credentials);

Event::fire(new Authenticating($user, $username));
event(new Authenticating($user, $username));

if ($this->getLdapAuthProvider()->auth()->attempt($username, $password)) {
Event::fire(new Authenticated($user));
event(new Authenticated($user));

return true;
}

Event::fire(new AuthenticationFailed($user));
event(new AuthenticationFailed($user));

return false;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Validation/Rules/DenyTrashed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Adldap\Laravel\Validation\Rules;

use Illuminate\Support\Facades\Event;
use Adldap\Laravel\Events\AuthenticatedModelTrashed;

class DenyTrashed extends Rule
Expand All @@ -13,7 +12,7 @@ class DenyTrashed extends Rule
public function isValid()
{
if ($this->isTrashed()) {
Event::fire(
event(
new AuthenticatedModelTrashed($this->user, $this->model)
);

Expand Down
2 changes: 1 addition & 1 deletion tests/DatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class DatabaseTestCase extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down