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

Commit 93a6ba6

Browse files
committed
Added user models to auth events
- Closes #456
1 parent 1c4666d commit 93a6ba6

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/Auth/DatabaseUserProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ public function validateCredentials(Authenticatable $model, array $credentials)
138138

139139
$model->save();
140140

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

143143
return true;
144144
}
145145

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

149149
// LDAP Authentication failed.

src/Events/AuthenticationRejected.php

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

55
use Adldap\Models\User;
6+
use Illuminate\Database\Eloquent\Model;
67

78
class AuthenticationRejected
89
{
@@ -13,13 +14,22 @@ class AuthenticationRejected
1314
*/
1415
public $user;
1516

17+
/**
18+
* The LDAP users eloquent model.
19+
*
20+
* @var Model|null
21+
*/
22+
public $model;
23+
1624
/**
1725
* Constructor.
1826
*
19-
* @param User $user
27+
* @param User $user
28+
* @param Model|null $model
2029
*/
21-
public function __construct(User $user)
30+
public function __construct(User $user, Model $model = null)
2231
{
2332
$this->user = $user;
33+
$this->model = $model;
2434
}
2535
}

src/Events/AuthenticationSuccessful.php

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

55
use Adldap\Models\User;
6+
use Illuminate\Database\Eloquent\Model;
67

78
class AuthenticationSuccessful
89
{
@@ -13,13 +14,22 @@ class AuthenticationSuccessful
1314
*/
1415
public $user;
1516

17+
/**
18+
* The authenticated LDAP users model.
19+
*
20+
* @var Model|null
21+
*/
22+
public $model;
23+
1624
/**
1725
* Constructor.
1826
*
19-
* @param User $user
27+
* @param User $user
28+
* @param Model|null $model
2029
*/
21-
public function __construct(User $user)
30+
public function __construct(User $user, Model $model = null)
2231
{
2332
$this->user = $user;
33+
$this->model = $model;
2434
}
2535
}

0 commit comments

Comments
 (0)