Added last login to user menu

This commit is contained in:
snipe 2017-03-03 18:28:13 -08:00
parent 2b4443f810
commit 51fccbdda4
5 changed files with 20 additions and 2 deletions

View file

@ -36,6 +36,7 @@ class UsersController extends Controller
'users.created_at',
'users.notes',
'users.company_id',
'users.last_login',
'users.deleted_at',
'users.activated'
])->with('manager', 'groups', 'userloc', 'company', 'throttle','assets','licenses','accessories','consumables')
@ -67,7 +68,7 @@ class UsersController extends Controller
[
'last_name','first_name','email','jobtitle','username','employee_num',
'assets','accessories', 'consumables','licenses','groups','activated','created_at',
'two_factor_enrolled','two_factor_optin'
'two_factor_enrolled','two_factor_optin','last_login'
];
$sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name';

View file

@ -156,10 +156,16 @@ class LoginController extends Controller
LOG::debug("Local authentication failed.");
return redirect()->back()->withInput()->with('error', trans('auth/message.account_not_found'));
} else {
$this->clearLoginAttempts($request);
}
}
if ($user = Auth::user()) {
$user->last_login = \Carbon::now();
\Log::debug('Last login:'.$user->last_login);
$user->save();
}
// Redirect to the users page
return redirect()->intended()->with('success', trans('auth/message.signin.success'));
}

View file

@ -43,6 +43,7 @@ class UsersTransformer
'company' => ($user->company) ? ['id' => $user->company->id,'name'=> e($user->company->name)] : null,
'created_at' => Helper::getFormattedDateObject($user->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($user->updated_at, 'datetime'),
'last_login' => Helper::getFormattedDateObject($user->last_login, 'datetime'),
];
$permissions_array['available_actions'] = [

View file

@ -176,6 +176,15 @@ class UserPresenter extends Presenter
"visible" => false,
'formatter' => 'dateDisplayFormatter'
],
[
"field" => "last_login",
"searchable" => false,
"sortable" => true,
"switchable" => true,
"title" => trans('general.last_login'),
"visible" => false,
'formatter' => 'dateDisplayFormatter'
],
[
"field" => "actions",
"searchable" => false,

View file

@ -88,6 +88,7 @@
'insufficient_permissions' => 'Insufficient permissions!',
'language' => 'Language',
'last' => 'Last',
'last_login' => 'Last Login',
'last_name' => 'Last Name',
'license' => 'License',
'license_report' => 'License Report',