You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used to have a custom operation for the currently logged in user that looked like this:
#[ApiResource(
collectionOperations: [
'current' => [
'method' => 'get',
'path' => '/current',
'controller' => CurrentUserAction::class,
],
],
)]
// CurrentUserAction.php
#[AsController]
final class CurrentUserAction extends AbstractController
{
public function __invoke($data): ?User
{
return $this->getUser();
}
}
which i turned into this:
new Get(
uriTemplate: '/current',
controller: CurrentUserAction::class,
normalizationContext: ['groups' => ['user:read', 'user:current']],
read: false,
write: false,
name: 'current',
),
// CurrentUserAction.php has not been changed
The problem now is that I don't get the user's iri in the @id for the new operation.
Instead I get @id: "/api/current". which is also correct but leads to problems. User can no longer be identified via the iri, I can't map newly created records to the current user, etc.
Shouldn't it also be possible that API platform can identify the user via this Iri by itself!?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey all,
I used to have a custom operation for the currently logged in user that looked like this:
which i turned into this:
The problem now is that I don't get the user's iri in the
@id
for the new operation.Instead I get
@id: "/api/current".
which is also correct but leads to problems. User can no longer be identified via the iri, I can't map newly created records to the current user, etc.Shouldn't it also be possible that API platform can identify the user via this Iri by itself!?
Beta Was this translation helpful? Give feedback.
All reactions