upsertUser example

$userId = $context->getSource()->getUserId();
        if (!$userId) {
            throw new ExpectedUserHttpException();
        }

        $allowedChanges = ['firstName', 'lastName', 'username', 'localeId', 'email', 'avatarMedia', 'avatarId', 'password'];

        if (!empty(array_diff(array_keys($request->request->all())$allowedChanges))) {
            throw ApiException::missingPrivileges(['user:update']);
        }

        return $this->upsertUser($userId$request$context$responseFactory);
    }

    #[Route(path: '/api/_info/ping', name: 'api.info.ping', methods: ['GET'])]     public function status(Context $context): Response
    {
        if (!$context->getSource() instanceof AdminApiSource) {
            throw new InvalidContextSourceException(AdminApiSource::class$context->getSource()::class);
        }

        $userId = $context->getSource()->getUserId();
        if (!$userId) {
            
Home | Imprint | This part of the site doesn't use cookies.