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

Commit

Permalink
Added user models to auth events
Browse files Browse the repository at this point in the history
- Closes #456
  • Loading branch information
stevebauman committed Jan 5, 2018
1 parent 1c4666d commit 93a6ba6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Auth/DatabaseUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ public function validateCredentials(Authenticatable $model, array $credentials)

$model->save();

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

return true;
}

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

// LDAP Authentication failed.
Expand Down
14 changes: 12 additions & 2 deletions src/Events/AuthenticationRejected.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Adldap\Laravel\Events;

use Adldap\Models\User;
use Illuminate\Database\Eloquent\Model;

class AuthenticationRejected
{
Expand All @@ -13,13 +14,22 @@ class AuthenticationRejected
*/
public $user;

/**
* The LDAP users eloquent model.
*
* @var Model|null
*/
public $model;

/**
* Constructor.
*
* @param User $user
* @param User $user
* @param Model|null $model
*/
public function __construct(User $user)
public function __construct(User $user, Model $model = null)
{
$this->user = $user;
$this->model = $model;
}
}
14 changes: 12 additions & 2 deletions src/Events/AuthenticationSuccessful.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Adldap\Laravel\Events;

use Adldap\Models\User;
use Illuminate\Database\Eloquent\Model;

class AuthenticationSuccessful
{
Expand All @@ -13,13 +14,22 @@ class AuthenticationSuccessful
*/
public $user;

/**
* The authenticated LDAP users model.
*
* @var Model|null
*/
public $model;

/**
* Constructor.
*
* @param User $user
* @param User $user
* @param Model|null $model
*/
public function __construct(User $user)
public function __construct(User $user, Model $model = null)
{
$this->user = $user;
$this->model = $model;
}
}

0 comments on commit 93a6ba6

Please sign in to comment.