mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-29 09:43:16 +00:00
Update verify_credentials api endpoint to improve performance
This commit is contained in:
parent
a982d1900f
commit
7df3540b08
2 changed files with 5 additions and 10 deletions
|
@ -122,6 +122,9 @@ class ApiV1Controller extends Controller
|
||||||
public function verifyCredentials(Request $request)
|
public function verifyCredentials(Request $request)
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 403);
|
abort_if(!$request->user(), 403);
|
||||||
|
|
||||||
|
abort_if($request->user()->status != null, 403);
|
||||||
|
|
||||||
$id = $request->user()->profile_id;
|
$id = $request->user()->profile_id;
|
||||||
|
|
||||||
$res = ProfileService::get($id);
|
$res = ProfileService::get($id);
|
||||||
|
|
|
@ -236,17 +236,9 @@ class BaseApiController extends Controller
|
||||||
abort_if(!$user, 403);
|
abort_if(!$user, 403);
|
||||||
if($user->status != null) {
|
if($user->status != null) {
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
return redirect('/login');
|
abort(403);
|
||||||
}
|
}
|
||||||
$key = 'user:last_active_at:id:'.$user->id;
|
$res = AccountService::get($user->profile_id);
|
||||||
$ttl = now()->addMinutes(5);
|
|
||||||
Cache::remember($key, $ttl, function() use($user) {
|
|
||||||
$user->last_active_at = now();
|
|
||||||
$user->save();
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
$resource = new Fractal\Resource\Item($user->profile, new AccountTransformer());
|
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue