mirror of
https://github.com/flarum/core.git
synced 2025-08-16 05:14:20 +02:00
Compare commits
1 Commits
dw/remove-
...
as/api-cli
Author | SHA1 | Date | |
---|---|---|---|
|
efa9d38d73 |
@@ -106,6 +106,7 @@ class ApiServiceProvider extends AbstractServiceProvider
|
|||||||
$this->container->singleton('flarum.api_client.exclude_middleware', function () {
|
$this->container->singleton('flarum.api_client.exclude_middleware', function () {
|
||||||
return [
|
return [
|
||||||
HttpMiddleware\InjectActorReference::class,
|
HttpMiddleware\InjectActorReference::class,
|
||||||
|
'flarum.api.error_handler',
|
||||||
HttpMiddleware\ParseJsonBody::class,
|
HttpMiddleware\ParseJsonBody::class,
|
||||||
Middleware\FakeHttpMethods::class,
|
Middleware\FakeHttpMethods::class,
|
||||||
HttpMiddleware\StartSession::class,
|
HttpMiddleware\StartSession::class,
|
||||||
|
@@ -116,11 +116,6 @@ class Discussion
|
|||||||
->withParentRequest($request)
|
->withParentRequest($request)
|
||||||
->withQueryParams($params)
|
->withQueryParams($params)
|
||||||
->get("/discussions/$id");
|
->get("/discussions/$id");
|
||||||
$statusCode = $response->getStatusCode();
|
|
||||||
|
|
||||||
if ($statusCode === 404) {
|
|
||||||
throw new RouteNotFoundException;
|
|
||||||
}
|
|
||||||
|
|
||||||
return json_decode($response->getBody());
|
return json_decode($response->getBody());
|
||||||
}
|
}
|
||||||
|
@@ -61,11 +61,6 @@ class User
|
|||||||
protected function getApiDocument(Request $request, string $username)
|
protected function getApiDocument(Request $request, string $username)
|
||||||
{
|
{
|
||||||
$response = $this->api->withParentRequest($request)->withQueryParams(['bySlug' => true])->get("/users/$username");
|
$response = $this->api->withParentRequest($request)->withQueryParams(['bySlug' => true])->get("/users/$username");
|
||||||
$statusCode = $response->getStatusCode();
|
|
||||||
|
|
||||||
if ($statusCode === 404) {
|
|
||||||
throw new ModelNotFoundException;
|
|
||||||
}
|
|
||||||
|
|
||||||
return json_decode($response->getBody());
|
return json_decode($response->getBody());
|
||||||
}
|
}
|
||||||
|
@@ -74,19 +74,17 @@ class LogInController implements RequestHandlerInterface
|
|||||||
|
|
||||||
$response = $this->apiClient->withParentRequest($request)->withBody($params)->post('/token');
|
$response = $this->apiClient->withParentRequest($request)->withBody($params)->post('/token');
|
||||||
|
|
||||||
if ($response->getStatusCode() === 200) {
|
$data = json_decode($response->getBody());
|
||||||
$data = json_decode($response->getBody());
|
|
||||||
|
|
||||||
$token = AccessToken::findValid($data->token);
|
$token = AccessToken::findValid($data->token);
|
||||||
|
|
||||||
$session = $request->getAttribute('session');
|
$session = $request->getAttribute('session');
|
||||||
$this->authenticator->logIn($session, $token);
|
$this->authenticator->logIn($session, $token);
|
||||||
|
|
||||||
$this->events->dispatch(new LoggedIn($this->users->findOrFail($data->userId), $token));
|
$this->events->dispatch(new LoggedIn($this->users->findOrFail($data->userId), $token));
|
||||||
|
|
||||||
if ($token instanceof RememberAccessToken) {
|
if ($token instanceof RememberAccessToken) {
|
||||||
$response = $this->rememberer->remember($response, $token);
|
$response = $this->rememberer->remember($response, $token);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
Reference in New Issue
Block a user