forked from mirror/pixelfed
Update verify_credentials endpoint
This commit is contained in:
parent
0b0bf59dd9
commit
be7eae8494
2 changed files with 29 additions and 1 deletions
|
@ -89,6 +89,34 @@ class ApiV1Controller extends Controller
|
|||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/accounts/verify_credentials
|
||||
*
|
||||
*
|
||||
* @return \App\Transformer\Api\AccountTransformer
|
||||
*/
|
||||
public function verifyCredentials(Request $request)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
$id = $request->user()->id;
|
||||
|
||||
$res = Cache::remember('mastoapi:user:account:id:'.$id, now()->addHours(6), function() use($id) {
|
||||
$profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail();
|
||||
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
$res['source'] = [
|
||||
'privacy' => $profile->is_private ? 'private' : 'public',
|
||||
'sensitive' => $profile->cw ? true : false,
|
||||
'language' => 'en',
|
||||
'note' => '',
|
||||
'fields' => []
|
||||
];
|
||||
return $res;
|
||||
});
|
||||
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/accounts/{id}
|
||||
*
|
||||
|
|
|
@ -77,7 +77,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('nodeinfo/2.0.json', 'FederationController@nodeinfo');
|
||||
|
||||
Route::group(['prefix' => 'v1'], function () {
|
||||
Route::get('accounts/verify_credentials', 'ApiController@verifyCredentials')->middleware('auth:api');
|
||||
Route::get('accounts/verify_credentials', 'Api\ApiV1Controller@verifyCredentials')->middleware('auth:api');
|
||||
Route::patch('accounts/update_credentials', 'Api\ApiV1Controller@accountUpdateCredentials')->middleware('auth:api');
|
||||
Route::get('accounts/relationships', 'Api\ApiV1Controller@accountRelationshipsById')->middleware('auth:api');
|
||||
Route::get('accounts/search', 'Api\ApiV1Controller@accountSearch')->middleware('auth:api');
|
||||
|
|
Loading…
Reference in a new issue