Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOUR-10278: Display and parse correct date/time for "Last Login" user column #6195

Merged
merged 2 commits into from
Feb 9, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions ProcessMaker/Listeners/LoginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@

namespace ProcessMaker\Listeners;

use Carbon\Carbon;
use ProcessMaker\Models\User;
use Illuminate\Auth\Events\Login;

class LoginListener
{
/**
* Handle the event.
* Updated the user "loggedin_at" attribute
*
* @param \Illuminate\Auth\Events\Login $event
*
* @param Illuminate\Auth\Events\Login $user
* @return void
*/
public function handle(Login $event)
public function handle(Login $event): void
{
// Grab our user that was logged in
$user = $event->user;
// Update the last_login

if (!$user instanceof User) {
return;
}

$user->timestamps = false;
$user->loggedin_at = Carbon::now();

$user->setAttribute('loggedin_at', now());
$user->save();
}
}
1 change: 1 addition & 0 deletions ProcessMaker/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class User extends Authenticatable implements HasMedia
'is_administrator' => 'bool',
'meta' => 'object',
'active_at' => 'datetime',
'loggedin_at' => 'datetime',
'schedule' => 'array',
'preferences_2fa' => 'array',
];
Expand Down