Skip to content

Commit fc98f13

Browse files
committed
Make Laravel appsec login success event more accurate
1 parent 3d4313f commit fc98f13

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/Integrations/Integrations/Laravel/LaravelIntegration.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -357,27 +357,27 @@ function ($This, $scope, $args, $loginSuccess) use ($integration) {
357357

358358
// Used by Laravel >= 5.0
359359
\DDTrace\hook_method(
360-
'Illuminate\Auth\SessionGuard',
361-
'setUser',
360+
'Illuminate\Auth\Events\Authenticated',
361+
'__construct',
362362
function ($This, $scope, $args) use ($integration) {
363363
$authClass = 'Illuminate\Contracts\Auth\Authenticatable';
364364
if (
365365
!function_exists('\datadog\appsec\track_user_login_success_event') ||
366-
!isset($args[0]) ||
367-
!$args[0] ||
368-
!($args[0] instanceof $authClass)
366+
!isset($args[1]) ||
367+
!$args[1] ||
368+
!($args[1] instanceof $authClass)
369369
) {
370370
return;
371371
}
372372
$metadata = [];
373-
if (isset($args[0]['name'])) {
374-
$metadata['name'] = $args[0]['name'];
373+
if (isset($args[1]['name'])) {
374+
$metadata['name'] = $args[1]['name'];
375375
}
376-
if (isset($args[0]['email'])) {
377-
$metadata['email'] = $args[0]['email'];
376+
if (isset($args[1]['email'])) {
377+
$metadata['email'] = $args[1]['email'];
378378
}
379379
\datadog\appsec\track_user_login_success_event(
380-
\method_exists($args[0], 'getAuthIdentifier') ? $args[0]->getAuthIdentifier() : '',
380+
\method_exists($args[1], 'getAuthIdentifier') ? $args[1]->getAuthIdentifier() : '',
381381
$metadata,
382382
true
383383
);
@@ -387,7 +387,7 @@ function ($This, $scope, $args) use ($integration) {
387387
// Used by Laravel < 5.0
388388
\DDTrace\hook_method(
389389
'Illuminate\Auth\Guard',
390-
'setUser',
390+
'login',
391391
function ($This, $scope, $args) use ($integration) {
392392
$authClass = 'Illuminate\Auth\UserInterface';
393393
if (

0 commit comments

Comments
 (0)