mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-27 01:19:35 +01:00
29 lines
615 B
PHP
29 lines
615 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class LogUserLastSeen
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
|
|
if( Auth::guard('api')->check() && !$request->bearerToken()) {
|
|
Auth::guard('api')->user()->last_seen_at = Carbon::now()->format('Y-m-d H:i:s');
|
|
Auth::guard('api')->user()->save();
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|